Skip to content

moreal/xunit-unity-runner

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xUnit.net Unity Runner

This program runs xUnit.net-based unit tests on Unity player so that a software work well on Unity's peculiar runtime environment, which differs from stable Mono.

You can download the executable binaries from the releases page.

This program takes one or more absolute paths to .NET assembly files (.dll) and run tests in them, e.g.:

./StandaloneLinux64 "$(pwd)"/YourTests.dll
StandaloneWindows64.exe C:\path\to\YourTests.dll

It also takes several options like -c/--select-class and -T/--exclude-trait-condition. See --help for details.

On macOS you need to invoke the actual executable binary in StandardOSX.app/Contents/MacOS/ directory, e.g.:

StandaloneOSX.app/Contents/MacOS/unity-xunit "$(pwd)"/YourTests.dll

Note that .dll files to test should target on .NET Framework (e.g., net461), not .NET Core.

CircleCI-style parallelism1

There are two options for running tests in distributed nodes: -D/--distributed and -s/--distributed-seed. The former option takes an argument in the N/M format, where N is the current node's zero-indexed number and M is the total number of distributed nodes. This option selects the subset of the test cases2 for the current node, and this guarantees two different nodes never run the same test case, which is redundant.

For example, the following options make the test execution to take advantage of CircleCI's parallelism:

--distributed=$CIRCLE_NODE_INDEX/$CIRCLE_NODE_TOTAL \
--distributed-seed=$CIRCLE_BUILD_NUM

FAQ

I got Magic number is wrong: 542 error. I'm on Linux.

If the TERM environment variable is not set or it's a value unsupported by Mono (e.g., xterm-256color) yet Unity player's built-in Mono runtime could throw such an exception. You could work around this by setting it xterm:

TERM=xterm ./StandaloneLinux64 "$(pwd)"/YourTests.dll

See also the related issue on the Mono project:

mono/mono#6752

Footnotes

  1. See also CircleCI's related docs: Running Tests in Parallel.

  2. Before a subset is selected, all test filters are applied first. Therefore, all distributed nodes have to apply the same set of filters.

About

Run Xunit tests on Unity player

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 96.5%
  • Shell 3.5%