Contents

CI / CD integration for Unit Tests

Unofficial Content

As discussed in the previous section Typical GeneXus development cycle, the software industry has evolved to enable a set of automation for boost quality and adopting DevOps practices. Continuous integration is a fundamental step to start working in a proper way with GXserver and GXtest. 

Continuous integration means that every time a developer pushes (aka commit) a change in a centralized repo in GXserver KB, that code will trigger some automation in order to check that recent changes can successfully build a new version without conflicts with other developments. Also, it will check that there are no missing references to be committed and that the build succeeds in a totally different environment than it was developed. With this step in your process, you will be avoiding the typical dev phase like “it works/builds on my machine”. Theoretically, CI means to integrate every time a developer makes a commit, but sometimes in your methodology, you want to do this less often but still getting often (maybe daily) feedback regarding your app status. In other words, that is continuously integrated.

CI tools are usually agnostic and you can integrate GeneXus with any CI tools using msbuild.exe on windows platforms. For example purposes, we will be showing some examples using Jenkins CI.

In the same way that you will use GeneXus Tasks such as OpenKB, BuildAll, RebuildAll, etc. for handling KB tasks and Team Development Tasks for handling GXServer, in order to run Unit test you need to call some extra task / step:

Run All Tests

To run your tests you need to configure 2 files:


com.Abstracta.GX.utest.Tasks.targets: This file defines the name of the task that runs the tests and the assembly file that contains it.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <UsingTask TaskName="com.Abstracta.GX.utest.Tasks.RunAllTestsTask"    AssemblyFile="com.Abstracta.GX.utest.Tasks.dll"/>
 </Project>

com.Abstracta.GX.utest.Tasks.msbuild: This file contains references to available tasks that can be called to execute.
Please note how this is combined with GeneXus Tasks that will be previously needed to run the tests.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <Import Project="$(GX_PROGRAM_DIR)\GeneXus.Tasks.targets"/>
   <Import Project="$(GX_PROGRAM_DIR)\Packages\com.Abstracta.GX.utest.Tasks.targets"/>
   <PropertyGroup>
      <KBPath>C:\Models\</KBPath>
   </PropertyGroup>
   <Target Name="RunAllTestsTask">
      <OpenKnowledgeBase Directory="$(KBPath)"/>
      <RunAllTestsTask />
      <CloseKnowledgeBase />
   </Target>
</Project>

Having this files configured properly, you can launch test task using this command line:

MSBuild.exe  /t:RunAllTestsTask /p:KBPath="C:\Models\KbTests" $env:GX_PROGRAM_DIR"\Packages\com.Abstracta.GX.utest.Tasks.msbuild"