Running UI tests under CI

Unofficial Content

In the same way that you will use GeneXus Tasks such as OpenKB, BuildAll, RebuildAll, etc. for handling Knowledge Base tasks and Team Development Tasks for handling GXServer, in order to run UI tests you will need to call some extra task / step. You can take a look at documentation of this tasks here.

How-to Run All your UI Tests in your KB

GXtest.msbuild: Let's assume that this is the filename of the MSbuild File that you are building to run UI Tests.

At the beggining, you will need to import two msbuild projects that contain predefined tasks which you are going to use on your file. Those projects are: GeneXus.Tasks.targets and GXtest.targets. 

The following is an example of msbuild file:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">    
  <Import Project="$(GX_PROGRAM_DIR)\GeneXus.Tasks.targets"/>    
  <Import Project="$(GX_PROGRAM_DIR)\GXtest.targets"/>

  <Target Name="RunAllTests">
    <OpenKnowledgeBase Directory="$(KBPath)"/>
    <SetActiveEnvironment EnvironmentName="$(EnvironmentName)"/>
    <UpdateTestRefs Type="$(TestType)"/>
    <BuildOne BuildCalled="true" ObjectName="Runner"/>
    <RunTests Type="$(TestType)"/>
    <CloseKnowledgeBase/>
  </Target>
</Project>

Having this file configured properly, you can launch all UI tests using this command line:

MSBuild.exe /t:RunAllTests /p:KBPath="C:\Models\KbTests" /p:EnvironmentName="CSharpWeb" /p:TestType="UI" $env:GX_PROGRAM_DIR"\GXtest.msbuild"

How-to Run a Test List (suite) of your KB

As well as the task Run All Tests, you will need to configure a msbuild file as is showed below: 

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">    
<Import Project="$(GX_PROGRAM_DIR)\GeneXus.Tasks.targets"/>    
<Import Project="$(GX_PROGRAM_DIR)\GXtest.targets"/>

<Target Name="RunTestsList">
    <OpenKnowledgeBase Directory="$(KBPath)"/>
    <SetActiveEnvironment EnvironmentName="$(EnvironmentName)"/>
    <UpdateTestRefs ExecutionDataFilePath="$(pathToJSON)"/>
    <BuildOne BuildCalled="true" ObjectName="Runner"/>
    <RunTestsList ExecutionDataFilePath="$(pathToJSON)"/>
    <CloseKnowledgeBase/>
</Target>
</Project>

Having this file configured properly, you can run a specific UI tests list using this command line:

MSBuild.exe /t:RunTestsList /p:KBPath="C:\Models\KbTests" /p:EnvironmentName="CSharpWeb" /p:pathToJSON="C:\Models\KBTests\TestList.json" $env:GX_PROGRAM_DIR"\GXtest.msbuild"