Unit Testing

Unit Test:
A unit test is a test that designed confirms the functionality of a small unit of work in a large system i.e. check the functionality of a method of that held inside a class and ensures that the method behaves as expected.
A unit test usually tests ONE specific requirement for ONE specific method. Unit tests are fit one requirement/one method rule. If your test violates the one requirement/one method rule than that means it is some kind of test, but not a unit test.

Characteristics of Unit Test
Unit tests have following attributes that further define them as a unit test:
• Targeted:
Unit tests that test one thing (including one set of inputs) at a time are targeted.
• Isolated:
The code you are testing should be isolated from other code in the application as well as any external dependencies or events
• Repeatable and Predictable:
A unit test should be capable of being run over and over and assuming that the code under test and the test itself have not changed, producing the same result.
• Independent:
Generally speaking you have no guarantee that your unit tests are going to run in any specific order. Nor should your tests expect or require this.

Benefits of using Unit Tests
• One can focus his/her entire efforts on that code portion (that he/she is testing).
• Don’t need to know the detail of other parts of the system (unless have direct dependency on them). This makes writing the test and resulting the code easier.
• If any defect causes inside the code then the test will fail, so will be easily find out where is the defect and recftor the code to fix the defect.

Unit tests are generally done by developers. So as soon as find any defect code refactoring and fixing defect done instantly.

Md. Mojammel Haque
Currently working as Lead Team (Application Architecture) at Raven Systems Ltd.

Passion for software development especially agile practices such as TDD & BDD with in depth knowledge of OOP, DDD, CQRS, ES, GoF, SOLID and PoEAA.

Over 6 years of software development experience ASP.NET. Has the ability to understand and transform complex business requirements into software ensuring applications are delivered on time.

Also experience in non Microsoft .NET technologies such as Dapper.Net, Subversion, Structure Map & AngularJs.

235 Total Views 1 Views Today
Developer Testing
Unit Testing New Code vs. Existing Code

Leave a Comment

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>