klawr icon indicating copy to clipboard operation
klawr copied to clipboard

NUnit integration

Open enlight opened this issue 10 years ago • 1 comments

The C# wrappers generated by KlawrCodeGenerator need a bunch of tests to ensure the method parameter and property data is being passed across the native/managed boundary as expected.

enlight avatar Sep 16 '14 16:09 enlight

Looks like the alpha release of NUnit v3 is due any day now, so it's probably best to wait until that happens instead of starting off with v2 and then upgrading.

The plan is roughly this:

  • Add a new Klawr.Tests assembly to Engine/Source/ThirdParty/Klawr/
  • Klawr.Tests will reference NUnit and Klawr.UnrealEngine assemblies.
  • Klawr.Tests will contain a UKlawrScriptComponent subclass that will execute the NUnit LocalTestRunner when ticked, which in turn will run tests in the current app domain.
  • Klawr.Tests will also contain some actual test classes to be run by NUnit.
  • The Klawr.Tests project will have a post-build event that copies it to the engine binaries directory (same one Klawr.UnrealEngine ends up in).
  • Create a new Tests directory in Engine/Plugins/Klawr/KlawrRuntimePlugin/Source/KlawrRuntimePlugin/Private/
  • Add a UE4 automation test to construct a UKlawScriptComponent and associate it with the corresponding C# type from Klawr.Tests, the native UKlawScriptComponent instance can then be ticked once to run all the tests in the Klawr.Tests assembly. Here's an example of a simple UE4 test.
  • Devise some way to display output/results from the NUnit test runner in the UE4 automation front end (or whatever runs those automation tests).

Potentially useful links about running NUnit in-process (though they relate to NUnit v2): https://stackoverflow.com/a/5241900 https://stackoverflow.com/a/13210613

NUnit v3 has the Test Engine API, which may be of some use.

enlight avatar Sep 22 '14 08:09 enlight