Jump to content
  • Advertisement
Sign in to follow this  
R

UE4 and unit tests

This topic is 515 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm trying to separate my logic into a different source set that I can unit test, I could set up a project with the unit tests correctly, but I don't know how to make unreal *see*, my other sources folder.

Any ideas or examples on how this should be done, also, if this is not a correct approach and I'm doing everything wrong, couyld you please shed some light?

Share this post


Link to post
Share on other sites
Advertisement

Create a new Module for your tests, add the Module you want to test as a dependency of your test module. You'll have to give it access to privates, which means exposing your classes with an export declaration.

Share this post


Link to post
Share on other sites

In addition to the advice of having a module for testing, keep in mind exactly what unit tests are meant to test.

 

Unit tests are test of the tiniest individual pieces of functionality.  They should never hit other systems or rely on external systems; those are different, possibly integration tests or feature test depending on what they are testing.

 

Be sure to research the topics of dependency injection, fake objects, and mock objects.  You will likely need to replace other systems in UE4 with mock objects so your code will use those fakes and mocks instead of the actual system. 

 

Unreal has out-of-the-box helpers for several kinds of automated testing.

Share this post


Link to post
Share on other sites
Thanks for the replies and recommendations, I actually know a lot about software development and testing, but not that much about unreal and its tools. I hacked a solution where I can write "logic" code that's uncoupled from unreal in another project and I can run unit tests on those. Later in I'll take a look at the unreal test tools, seems to be very interesting.
Thanks again, thisnis my first post and I feel very welcome! :D

Share this post


Link to post
Share on other sites
Thanks, I will take a look at those ideas, I have a ton of experience with software development but 0 with unreal and green development, all the help I can get is very appreciated!
I just came up with a hack solution where I build the game logic code without anything unreal and run the tests against those files by creating a cmake project that takes the files straight from that folder. It's working fine so far, but I think the modules solution is the way to go.
I'll probably take a look at the unreal testing tools some day, but for now I'll just use Google test and Google mock because that seems to be standard knowledge I can use in any c++ project and not only with unreal.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!