Run automated testing from command line

How do you run the command line in your jenkins pipeline? using the bat command?
I have this:

stage( "UnitTests" ) {
    try {
        bat "\"${env.UE_ROOT_FOLDER}\\Engine\\Binaries\\Win64\\UE4Editor-Cmd.exe\" \"${env.WORKSPACE}\\${env.PROJECT_NAME}.uproject\" -ExecCmds=\"Automation RunTests ${env.PROJECT_NAME}\" -unattended -nopause -testexit=\"Automation Test Queue Empty\" -log -log=RunTests.log"
    } catch ( Exception e ) {
    }
}

but before the editor tries to run the unit tests, I have this error:

[2018.11.06-18.45.01:561][  0]LogD3D11RHI: Error: D3DRHI->GetFactory()->CreateSwapChain(DXGIDevice, &SwapChainDesc, SwapChain.GetInitReference()) failed 
at D:\Build\++UE4\Sync\Engine\Source\Runtime\Windows\D3D11RHI\Private\Windows\WindowsD3D11Viewport.cpp:126 
with error 887A0022

I guess thatā€™s because the editor is created in the bat process and does not have a chance to create the RHI (I tried with -NullRHI, with the same error)

OK I found the issue. The slave was connected to the master from a Windows Service, which does not have the rights to create the DX11 swap chain.
When connecting using the JLNP file, it does work :slight_smile:

Iā€™ll have a look at the warnings regexp tomorrow :slight_smile:

I am running it from a batch script, containing the command line I posted above:

	stage("Run Unit Tests") {
		steps {
			bat 'Tools\\BuildSystem\\run_unit_tests.bat'
		}
	}

Your problem might be that your Jenkins build machine needs to have a DirectX 11 GPU, and also perhaps a user session open. -NullRHI should solve this, I think, but it crashed on UE4.20, I had to backport a fix from 4.21 to have it work

I had a look and indeed the cleanest way would be to comvert the JSON file from the report into a valid jUnit XML file. I quickly looked for any plugin which would help do that but did not find any.
So for now, I donā€™t export the report, and I configured a Warnings task to parse the log.

Here is the regexp:
^\s*.]AutomationTestingLog: Error:\s(.)((\d+)): (.)(.*)$

And the mapping script:
import hudson.plugins.warnings.parser.Warning
import hudson.plugins.analysis.util.model.Priority

String category = "Unit Tests"
String fileName = matcher.group( 1 )
String lineNumber = matcher.group( 2 )
String message = matcher.group( 3 )
Priority priority = Priority.HIGH;

return new Warning( fileName, Integer.parseInt(lineNumber), "UE4", category, message, priority );

I managed to do just that, and wrote a blog post about it : UE4 Unit Tests in Jenkins | MICHAEL DELVA

adding small note:

The opened session frontend issue also affects 4.16 so most likely every version above until 4.21

You can save presets which are saved into a config file. Can a saved preset be used in a command line invocation? It would be great to configure the list in the Session Frontend and then use it in a command line invocation. Using the name of the preset in the -execcmds is a fail.

Hi,
there is any chance that someone has a clue on how to run Automation Tests with command line in an UE5 project?
It seems that the cmd lines changed from ue4, I donā€™t see anything when I try to launch [UEBinaryPath]UnrealEditor-Cmd.exe "[myProjectPath]MyProject.uproject" -unattended -nopause -NullRHI -ExecCmds="Automation List.
Did I miss something ?

EDIT: Something weird: When i run all tests like so[UEBinaryPath]UnrealEditor-Cmd.exe "[myProjectPath]MyProject.uproject" -unattended -nopause -NullRHI -ExecCmds="Automation RunAll; quit" -TestExit="Automation Test Queue Empty" -log -log=RunTests.log -ReportExportPath="!PROJ_DIR!\TestsReports\reports\ue" they are successfully launched.

But when I try to run a specific test using
[UEBinaryPath]UnrealEditor-Cmd.exe "[myProjectPath]MyProject.uproject" -unattended -nopause -NullRHI -ExecCmds="Automation RunTests MyProject.Test1; quit" -TestExit="Automation Test Queue Empty" -log -log=RunTests.log -ReportExportPath="!PROJ_DIR!\TestsReports\reports\ue"
i get
ERROR: No automation tests matched 'MyProject.Test1' (I use the pretty name)

And in the frontend window in editor i can see this test

OK my bad, iā€™ve just forgotten to declare the module of my project in the .uproject file :person_facepalming:ā€¦ sorry

Does somebody know if i can Run All the test except one via CMD. Iā€™m trying to run the test for System and i have a fatal error just for one test. So I want to exclude that test.

1 Like

@ptherrien24

Iā€™m thrilled to share that Iā€™m currently working on a new automated testing plugin for Unreal Engine. One of the standout features of this plugin is the support for tags and priorities for tests. This means you can now run tests with specific tags or even based on a required priority, making the testing process more streamlined and efficient.

I believe this plugin can be a game-changer for many developers, especially those working on larger projects where efficient testing becomes crucial.

Iā€™d love to hear your thoughts, feedback, and any suggestions you might have. Do you think this is something youā€™d use in your projects? Are there any additional features youā€™d like to see?

Thank you in advance for your insights and feedback. Together, we can make this tool even better for the Unreal Engine community!

Warm regards,
RamĆ³n

@Ramon_Janousch
Hello, any news about new automated testing plugin ? Are you still working on it?

1 Like

Hi :slight_smile:
Weā€™ve started working on a new version of the plugin and will publish it on Github in the next few weeks.
What are your goals with the plugin?

Im launching unit, functional, perf test by it. im using test on single node.

i couldā€™nt set automation gauntlet system, didnā€™t find how to setup nodes.

a few issues what i have.

  1. Donā€™t have any report if client/editor crush while doing tests
  2. Canā€™t continue other tests after crush
  3. Screenshot comparing with calling from automation spec, working weird, its making screen with different resulution every time.
  4. Have to add custom method for expected errors/warnign for flacky not fixeble problems. (add expected error with Occurrences=0, AddError, right after)
  5. Didnā€™t found way to set LattentTimout for tests, incide created test class.