Why does generating project delete my test files?


I’m trying to create tests for my project but it wouldn’t show up in the Session Frontend window and when I regenerate the project files they also get deleted from the solution.

I placed them in the general private/Tests/[name]Test.cpp location which was recommended by the documentation.

My code was exactly the one you find under the minimal example part here. I also tried to include “Misc/AutomationTest.h” with no effect.

Could someone help me with getting it to work? Testing is kinda an important thing and it’s a bit frustrating that the example code fails for some reason.

First you need to understand that what you see in file explorer in solution does not need to reflect what is in actual file system. Files you see there are file added to list VS solution file and item in that list don’t represent file in file system

So by that, considering you seeing it as “delete” i assume you add files VS in solution.

If you did that that means your files been made in “Intermediate” folder not is “Source”, as UE4 expect you to use class generator in UE4 editor not solution. You tests should still be in intermediate, but because they not in “Source” which is only folder put in to consideration during project file generation that simply not added to solution list, it also won’t be considered for compiletion UBT (which btw the same tool generated VS files). So if oyu want to add empty files, make them in file menager outside VS and regenerate project file.

It might be wierd that you need to do this but, but might be because incompatibility of UE4 conventions with VS, where computer specific files (like generated VS files) should be in Intermediate not Source

That said i just assume from info you given, as this is No.1 reason why files disappear from solution and why files are not compiled

Thank you! It really was the problem. Weird workflow but creating an empty class only to delete the header and put the testing code into the remaining cpp file made things work. My test also shows up now. :slight_smile: