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.
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.
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.
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.
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.