Creating Unit Tests

First, you need some code to test. Imagine you have a Rectangle class that exposes methods for math calculations on a rectangle’s perimeter and area. Create a new class library, name it UnitTestDemo; then rename Class1.vb as Rectangle.vb and write the following code:

image

Imagine you want to test both methods to check if they work correctly but inside an isolated environment, abstracted from the original project. In the code editor select both methods; then right-click and select Create Unit Tests. This launches the Create Unit Tests dialog, where you can select objects to add to the test project. Expand the UnitTestDemo namespace ...

Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.