How do I unit test my blueprint functions?

Apparently this is possible for C++, but what about blueprints?

I’m not sure what you mean by “Test,” but most people use the PRINT node to verify what’s happening throughout the code, similar to LOG in most other languages.

-Sterling

e.g. in C++ (with GoogleTest), I can write this test suite:

TEST_F(TestMyFunction, Zero) {
  ASSERT_EQ(MyFunction(0), 0);
}
TEST_F(TestMyFunction, Two) {
  ASSERT_EQ(MyFunction(2), 4);
}
TEST_F(TestMyFunction, NegativeTwo) {
  ASSERT_EQ(MyFunction(-2), 4);
}   

And then I can run all the tests at once every time I build my project. If any of them fail, I get a report. This way I don’t have to manually test the feature every time I make a change, but can rely on the test suite.

See also: Unit testing - Wikipedia

Hi, in UE 4.14 the functional testing is more or less usable for this ( I made a video demonstrating this Tutorial: Automated Functional Testing in Blueprints in UE 4.14 - YouTube ). It’s not really unit testing, but it’s actually pretty close to what you need for unit testing and it should be pretty easy to build something on top to allow for simple assertions and such.

2 Likes