Ad space (banner)
๐Ÿ”ทVB.NET Lessons
Lesson 37 / 68

Writing several tests together (multiple test cases)

This lesson covers running several test cases together in VB.NET, with the aim of understanding what a body of unit tests looks like.

Listing pairs of input and expected result in advance, then comparing each against the actual result, lets you test a body of cases efficiently — and without the gaps that checking by hand leaves.

The sample code gathers the cases into an array of (a, b, expected) tuples, passes each to Add() in a For statement, checks the result, and counts how many passed. Adding a case is all it takes to add a check.

A common early stumble is testing only the ordinary cases and forgetting the boundaries. Covering the easily overlooked ones — (-1, 1, 0), (0, 0, 0) — is what matters.

In professional work, re-running every test automatically after each change — regression testing — to confirm nothing else broke is a widely adopted practice.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run VB.NET directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)