Unit Testing - amitbhilagude/userfullinks GitHub Wiki
Overview
Three Types
MS Test
NUnit
xUnit
All three test methods are good. They use different NuGet packages for Unit tests and Test adapters.
Test Adapter is used for runtime test discovery. If you remove this package. No test will be shown in Test explorer.
MS Test
Class Attribute: [TestClass]
Initialise Test cases Method: [TestInitialize]
Each Test case method: [TestMethod]
NUnit
Class Attribute: [Test Fixture]
Initialise Test cases Method: [SetUp]
Each Test case method: [Test]
xUnit
Class Attribute: No decoration
Initialise Test cases Method: Replaced with the constructor of a class
Each Test case method: [Fact]
Visual Studio Enterprise Version Features
Code Coverage
Gives detailed information about how much code coverage we have for each method.
Live Unit Testing
Gives you to test your code during development.
You don't have to go to test explorer. you can start live testing by putting a breakpoint. it also gives an indication if this method is covered by test cases.
Unit Testing for Static methods for NUnit where every test cases works in Isolation.
Challenge with Static method if there is class A is calling Static class B then we can't test. If static class B is referring app setting for DB connections
Better option is to use Dependency injection and use class B through DI only.
Best practices
Use NCrunch as a test runner. A good option is to run tests in the background and highlight the issue run time.
https://www.ncrunch.net/