Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Is it possible to add an AutomationTest in a game module?

I would like to add some unit tests for code contained in the game module. I'm following the documentation found at https://docs.unrealengine.com/latest/INT/Programming/Automation/TechnicalGuide/index.html, registering the AutomationTest using IMPLEMENT_SIMPLE_AUTOMATION_TEST and including its corresponding RunTest method.

However, seems like the test is not registered, and never shows up in the Session Frontend > Automation list.

Are Automation Tests only intended for Engine modules? Or perhaps I'm missing an undocumented step?

Product Version: Not Selected
more ▼

asked Jul 25 '14 at 09:49 PM in C++ Programming

avatar image

46 2 6 13

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Good news, AutomationTest are fully functional from Game module. I've got I first failing test working, just adding a source file MyClassTest.cpp inside a /Test folder in my regular game source dir containing :

 #include "YourGameModule.h"
 #include "AutomationTest.h"
 IMPLEMENT_SIMPLE_AUTOMATION_TEST(FYourTestClass, "Core.Misc.YourCat", EAutomationTestFlags::ATF_SmokeTest)
 bool FYourTestClass::RunTest( const FString& Parameters )
     AddError(FString::Printf(TEXT("The testing goat says NO! Hourray! Goto coding! ")));
     return true;

The test was automatically added in the Session Frontend. Nothing to do.

I've not longer experienced UE4 testing, but Engine/Source/Runtime/Core/Private/Tests/ should be a good starting point!

more ▼

answered Aug 19 '14 at 01:36 PM

avatar image

101 4 11 20

avatar image JMigCarrier Aug 19 '14 at 08:48 PM

You are right!

It is working. My mistake was using ATF_Game as test flag, it leaves the test out from running in the editor. Using ATF_SmokeTest (or ATF_Editor, ATF_ApplicationMask) allows the test class to appear on the Session Frontend list.

avatar image Fire-Dragon-DoL Mar 14 '15 at 04:20 PM

Did you manage to get tests hot reload? I can't really use automation testing if I can't reload tests

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

How do you run tests marked with ATF_Game? There are automation tests I'd like to write that would launch the game and test stuff in the world.

more ▼

answered Dec 12 '14 at 08:08 PM

avatar image

91 5 8 12

avatar image jcoombs Dec 12 '14 at 09:39 PM

Nevermind - I found the answer in the source code (Engine\Source\Programs\UnrealBuildTool\System\RulesCompiler.cs). Running this command line will execute the ATF_Game tests

"%UE4EnginePath%\Build\BatchFiles\RunUAT.bat" BuildCookRun -project=%ProjectPath% -run -RunAutomationTests -unattended -nullrhi -NoP4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question