To make MSBuild targets easier, you will find a GXtest.msbuild file in your GeneXus IDE installation folder.
For example, this is how the “RunTests” target (which includes RunTests task) looks like in the GXtest.msbuild file:
<Target Name="RunTests">
<OpenKnowledgeBase Directory="$(KBPath)"/>
<SetActiveEnvironment EnvironmentName="$(EnvironmentName)"/>
<ItemGroup>
<UnitTests Include="$(UnitTests)"/>
<WebTests Include="$(WebTests)"/>
<Suites Include="$(Suites)"/>
</ItemGroup>
<RunTests Type="$(TestType)" TestObjects="$(TestObjects);$(UnitTests);$(WebTests);$(Suites)"
Browser="$(Browser)" BaseURL="$(BaseURL)" FileUploadBasePath="$(FileUploadBasePath)"
ScreenshotMode="$(ScreenshotMode)" HtmlMode="$(HtmlMode)" Arguments="$(Arguments)"
DetailedResults="$(DetailedResults)"
ServerUserName="$(GXServerUser)" ServerPassword="$(GXServerPass)"
AllowFailedTests="$(AllowFailedTests)" ResultsFile="$(ResultsFile)">
<Output TaskParameter="ExecutedCount" PropertyName="ExecutedCount"/>
<Output TaskParameter="SuccessCount" PropertyName="SuccessCount"/>
<Output TaskParameter="ErrorCount" PropertyName="ErrorCount"/>
<Output TaskParameter="WarningCount" PropertyName="WarningCount"/>
<Output TaskParameter="SkippedCount" PropertyName="SkippedCount"/>
<Output TaskParameter="ResultsFile" PropertyName="ResultsFile"/>
<!-- Type can be 'UI' to run only UI tests, 'Unit' to run only unit tests or 'All' to run both. -->
</RunTests>
<JUnitExportTests SourceResultsFile="$(ResultsFile)" JUnitTestFilePath="$(JUnitTestFilePath)" >
<Output TaskParameter="JUnitTestFilePath" PropertyName="JUnitTestFilePathOutput" />
</JUnitExportTests>
<ExportResultsToAllure TargetDir="$(AllureResultsPath)" Properties="KB=$(KBPath);Environment=$(EnvironmentName);$(TestingEnvironment)">
<Output TaskParameter="OutputFiles" PropertyName="OutputFiles" />
</ExportResultsToAllure>
<CloseKnowledgeBase/>
</Target>
*Note: you have to set the server user (local or gxtechnical) and password to run the tasks.
The following command line example runs all unit tests in the KB:
MSBuild.exe /t:RunTests /p:KBPath="C:\Models\KbTests" /p:EnvironmentName="CSharpWeb" /p:TestType="Unit" /p:GXServerUser="local\admin" /p:GXServerPass="password" PATH_TO_YOUR\GXtest.msbuild
The following command line example runs 3 web UI tests (TestName1, TestName2, and TestName3) using Google Chrome headless:
MSBuild.exe /t:RunTests /p:KBPath="C:\Models\KbTests" /p:EnvironmentName="CSharpWeb" /p:TestObjects="TestName1;TestName2;TestName3" /p:Browser="Chrome" /p:Arguments="--headless" /p:GXServerUser="local\admin" /p:GXServerPass="password" PATH_TO_YOUR\GXtest.msbuild
You can run any type of test object by passing it as the TestObjects parameter, e.g. a unit test, a web UI test, and a test suite.
MSBuild.exe /t:RunTests /p:KBPath="C:\Models\KbTests" /p:EnvironmentName="CSharpWeb" /p:TestObjects="AUnitTest;AWebUITest;ATestSuite" /p:GXServerUser="local\admin" /p:GXServerPass="password" PATH_TO_YOUR\GXtest.msbuild
You can run any type of test in parallel by setting the target file where results will be saved. For example, if you have 2 test suites to run in parallel you can do:
MSBuild.exe /t:RunTests /p:KBPath="C:\Models\KbTests" /p:EnvironmentName="CSharpWeb" /p:TestObjects="TestSuite1" /p:ResultsFile="C:/TestSuite1.xml" /p:GXServerUser="local\admin" /p:GXServerPass="password" PATH_TO_YOUR\GXtest.msbuild
MSBuild.exe /t:RunTests /p:KBPath="C:\Models\KbTests" /p:EnvironmentName="CSharpWeb" /p:TestObjects="TestSuite2" /p:ResultsFile="C:/TestSuite2.xml" /p:GXServerUser="local\admin" /p:GXServerPass="password" PATH_TO_YOUR\GXtest.msbuild
Note: for any command execution you could override the properties set for a KB/environment, such as Browser, Base URL, Screenshot and HTML saving modes, Arguments, etc.