Hiep
Hiep

Reputation: 2612

xUnit.net - How a custom tests runner can give arguments to the unit tests?

Base on this excellent sample

I'm able to create a custom Test Runner to execute any external tests dlls. Something like:

testReport = MyTestRunner.Run(@"External_Unit_Test.dll");

MyTestRunner wants to give some arguments / configurations to External_Unit_Test.dll before its run. How to achieve that?

For now MyTestRunner will write the arguments / configuration in a temporary file, then External_Unit_Test.dll will read the configuration from it.

Is there a better way to communicate between MyTestRunner and External_Unit_Test.dll?

The question is also asked here on GitHub

Upvotes: 0

Views: 1542

Answers (1)

Ruben Bartelink
Ruben Bartelink

Reputation: 61893

As covered in various xUnit issues, there is no specific facility of xUnit.net wrt this.

Normally such context is passed through Environment Variables (perhaps with a level of indirection by packing stuff up in a config file of some kind and then passing the path to that).

This lowest common denominator approach also works well with typical CI rigs.

Upvotes: 1

Related Questions