xUnit setup help

DMcLennanDMcLennan GBMember ✭✭

As the title says. I'm a newbie to this and the tutorials I can find seem outdated or are not clear for a beginner like me.

I have a .NET Standard project. The old tutorial here says to add a PCL, an Android and an iOS project to my solution.

I'm unsure about project templates. Since I'm on .NET Standard, do I add a .NET Standard Class Library? Or just "Class Library (.NET Framework)"? (As a side note, if I wanted to try NUnit would it use the same?)

And for Android/iOS which project templates should I use? For Android I tried "Blank App (Android)" but had problems installing the devices NuGet and after that worked an error after copying in MainActivity.txt

Finally, I'm confused on how to use the xUnit console runner, where it has to point to.

Thank you.

Best Answer

  • mattwardmattward GB Xamurai
    Accepted Answer

    For the .NET Standard project you could create a .NET Core - Tests - xUnit Test project and then reference the .NET Standard project. It is also possible to create a normal C# class library project (one that targets .NET Framework), install the xunit NuGet packages (xunit and xunit.runner.visualstudio), then reference the .NET Standard project from the class library project. Then you should be able to run and debug your tests directly in Visual Studio or Visual Studio for Mac.

    I have not used the xunit device runners for iOS or Android so cannot comment on that.

Answers

  • mattwardmattward GBMember Xamurai
    Accepted Answer

    For the .NET Standard project you could create a .NET Core - Tests - xUnit Test project and then reference the .NET Standard project. It is also possible to create a normal C# class library project (one that targets .NET Framework), install the xunit NuGet packages (xunit and xunit.runner.visualstudio), then reference the .NET Standard project from the class library project. Then you should be able to run and debug your tests directly in Visual Studio or Visual Studio for Mac.

    I have not used the xunit device runners for iOS or Android so cannot comment on that.

Sign In or Register to comment.