Forum Xamarin Cross Platform with Xamarin

NUnit tests for shared project


there are 3 projects: shared, iOS and Android.
I want to run NUnit-Tests for functionalities in the shared project (Non-UI).

How do I have to proceed?



  • StarclusterStarcluster Member ✭✭

    Can nobody help?

  • ChristopheBERNARDChristopheBERNARD BEMember ✭✭✭✭✭

    Hello @Starcluster
    In the shared project you have all your viewModel and models also just added a project as NUnit test project

  • StarclusterStarcluster Member ✭✭

    I created a test project with the following steps:

    • create NUnit test project
    • add project references (Shared and Android)
    • add package references

    When i try to run the project a ton of errors occur. e.g. "The name 'InitializeComponent' does not exist in the current context". Names of Views (x:Name) cannot be found and so on...

    I think the UI-Components cause the problems. Do i have to create a separate project with only the business logic inside (instead of Shared And Android)? I want to prevent code duplicates...

  • ChristopheBERNARDChristopheBERNARD BEMember ✭✭✭✭✭

    hello @startcluster
    you need just add shared reference to the nUnit project.
    shared project will contains only viewModel / models / and so on ...

Sign In or Register to comment.