Is it possible to fake other OS platforms for unit tests?

Viewed 120

I make cross-platform and multi platform tools. They for example load different modules depending on the runtime platform.

Obviously, I won't be able to fully test them in Visual Studio on Windows, but I could at least test if they detect the runtime platform correctly and if they load appropriate modules.

The system checks are pretty standard:

if (RuntimeInformation.IsOsPlatform(OSPlatform.Linux)) { /* do the Linux thing */ }

I test Linux code just by publishing a Linux executable (as standard console application) and then just output the test results to the console.

It would be cool if I would be able to add some XUnit tests to my Visual Studio solution that test some of this code.

0 Answers
Related