Unit Test Errors

I am starting to go through Mosh’s Unit Testing course. I am using Visual Studio 2019 and I am trying to run the projects/ tests but keep getting these errors,


I have searched StackOverflow and google but can only find answers going over my head, any idea what how to fix this?

Make sure the project has the Program.cs file with a Main method and then the other error should resolve itself.

I will try that; should I try it even if the main method doesn’t do anything? Or how do I run the tests on the methods in the different class libraries? Hopefully that makes sense:)

Yes, you’ll want to have it even if it doesn’t do anything. In order to run the tests you’ll wanna make sure you have the Visual Studio test runner I think? I use Rider so I might be wrong about that one.

Check the project type of your TestNinja project. You usually test library projects and these don’t require a Main method.

There is no startup project and the output type is class library. Is that what is expected?
I now get this error message.
image

You neither (Ctrl-)F5 library- nor test-projects. Use Ctrl-A, R to run the tests.

1 Like

Thanks, seems like I should have understood that… but oh well at least I will remember it now:)