Unit testing blueprints with Automation System

I’m currently working on a plugin for an online service that is made up of native C++ and a Blueprint wrapper layer. I’ve just got to the stage where I need to automate testing of the various functions on our build server. It’s fairly straightforward to setup and test the C++ functions, but I’m at as loss as to the best way to test the Blueprint wrapper.

I need to be able to do this through the Automation System to allow the tests to execute when building on the automated build server. Is there a way that I could load a “Unit test” scene and execute the blueprints though there? Or is there a better option? Any advice would be greatly appreciated.

This is a long shot guess but what about blutility?

Thanks for the reply, I’ve never heard of Blutility but it looks like it might be useful. I’ll have to spend some more time looking into it.

Hey Silent8Strike-

I believe what you’re trying to do is possible however I will need to test the process before I can say for sure. I’ll update you once I’m able to make a test case.

Cheers

Thanks , looking forward to seeing what you come up with!

Hey Silent8Strike!

Quick question on your implementation at a high level while I help look into this for you. Are you creating a Blueprint based off your C++ class, then attaching a Blueprint Interface to it? If not, just a quick breakdown on the implementation would be super helpful.

Thanks!

Hi Bob,

Right now the Blueprint layer to access my C++ functions is modeled after the OnlineSubsystem’s latent async task nodes. This seemed like the cleanest way to implement the C++ functions in Blueprint as almost all of them are latent.

Currently I have a proxy UObject class that consists of BlueprintCallable functions that match all my native C++ functions. These functions do nothing but call my native C++ code. Again, this is based on the OnlineSubsystem’s blueprint node handling, so I’m not sure I can explain it adequately.

The hope was that we could automate running all the blueprint functions on build, therefor testing the Blueprint and native C++ automatically and at the same time. If we end up having to run it manually its not the end of the world, but the automation makes catching errors a lot more likely.

Let me know if you need any more details.

Thanks for the additional info!

Another quick set of question(s)/comments :slight_smile:

Is this proxy object being used by anything else, or just simply a test wrapper for the C++ object? I only ask because if there is no other logic in the proxy object, what do you wish to test? Just that the Blueprints exposure works?

Assuming your proxy class has its method(s) being called from a blueprint, you should be able to use the native UE4 Automation Framework to load that blueprint asset and call your exposed functions in a unit test form.

Here’s some more info on UE4’s automation system:

https://docs.unrealengine.com/latest/INT/Programming/Automation/index.htm

The documentation needs some love, but if you have access to source, you can take a look at EditorAutomationTests.cpp as an example of how to implement them. (Under …Engine\Source\Editor\UnrealEd\Private\Tests)

You can also run the tests from a command line, which should help get them running on your CIS/Build system in an automated fashion.

Thanks for getting back to me so quickly. The proxy object is not being used for anything else, so yes I’m just looking to confirm the blueprint calls are working correctly. Most of the BP calls are straight pass though to the C++, but others do some conversion of types and such so we just need to make sure everything works.

I’ve actually been working on setting up a blueprint as a unit test framework. It currently consists of several blueprints that contain all the methods to test, plus a master test blueprint that manages logging errors/success and cycling through the test blueprints.

As long as I can load and execute that via the automation system I should be good to go. I’ll dig through the source and docs you mentioned and see if I can hook it up.

In 4.14 they made some changes to the functional testing so it’s now more or less usable to write some basic tests in the blueprints ( I made a video demonstrating this Tutorial: Automated Functional Testing in Blueprints in UE 4.14 - YouTube ) . Should be possible to test any blueprint with it, we’d just need to add some assertions on top of this functional test to make this more “unit-testing” like.