UNIT TESTING
Unit testing is the process in which tiny testable parts of a program, referred to as units,are independently tested for expected functionality
It could be either automated or manually done
There is a lot of different approaches to testing an application
Different kinds of Test Approaches
-Acceptance testing -Load testing -Regression testing -Smoke testing
-Black box testing -System testing -Unit testing -White box testing
-Compatibility testing -Conformance testing -Functional testing -Integration testing
TEST DRIVEN DEVELOPMENT
Process that uses unit tests to drive the design of software
Advantages
-Clear intentions -knowing what you want and then creating it
-Encourage decoupling
-Easier to catch bugs early on
-Forces writing test cases early and lessens chance of missing test cases later
-Help achieve YAGNI or “you ain’t gonna need it”
TDD STEPS : RED,GREEN AND REFACTOR
1.Red -creating a test that will fail
2.Green -updating a test to pass
3.Refactor -updating your code to meet coding standards and minimize duplication
SOLID REFACTORING
Single responsibility principle(SRP)
A class should have one and only one reason to change
Open/closed principle(OCP)
You should be able to extend a classes bheaviour,without modifying it
Liskov substitution principle(SLP)
Derived classes must be substitutable for their base classes
Interface segregation principle(ISP)
Make fine-grained interfaces that are client specific
Dependency inversion principle(DIP)
Depent on abstractions, not on concretions(Interfaces are abstractions(no functioning methods; just signatures)
DIFFERENT KINDS OF TESTING TOOLS
1.MSTest -official unit tester by Microsoft(much better than for integration-based testing)
2.NUnit -open source unit-testing framework inspired by Java’s unit(really fast and works either
İn 32 bit mode or 64 bit mode)
3.xUnit -open source unit tester developed for .NET(you can set up yor tests in one area and then apply
Them to multiple test across your project
MOCKING FRAMEWORKS
1.FakeItEasy
Mocking framework where objects are considered fakes but usage determines whether they’re mock or stubs
2.NSubstitute
Mocking framework syntax that is more succinct and concise
3.Moq
Mocking library developed from scratch to take full advantage of .NET
Excellent write-up. I absolutely love this site. Keep writing!
Hello from Happykiddi.