0% found this document useful (0 votes)
27 views1 page

Runner

The document explains the concept of test runners, specifically using JUnit to execute test cases, with an example of a TestRunner class. It also outlines key JUnit classes such as Assert, TestCase, and TestResult that are essential for writing and testing JUnit tests. The main purpose of these classes is to facilitate the testing process and collect results from test executions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views1 page

Runner

The document explains the concept of test runners, specifically using JUnit to execute test cases, with an example of a TestRunner class. It also outlines key JUnit classes such as Assert, TestCase, and TestResult that are essential for writing and testing JUnit tests. The main purpose of these classes is to facilitate the testing process and collect results from test executions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Test Runners

Test runner is used for executing the test cases. Here is an example that assumes
the test class TestJunit already exists.
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;

public class TestRunner {


public static void main(String[] args) {
Result result = JUnitCore.runClasses(TestJunit.class);

for (Failure failure : result.getFailures()) {


System.out.println(failure.toString());
}

System.out.println(result.wasSuccessful());
}
}

JUnit Classes
JUnit classes are important classes, used in writing and testing JUnits. Some of the
important classes are −
 Assert − Contains a set of assert methods.
 TestCase − Contains a test case that defines the fixture to run multiple tests.
 TestResult − Contains methods to collect the results of executing a test
case.

You might also like