ABOUT THE COURSEA strong foundation of understanding JUnit testing concepts is important for Unit testing. In this Course, you will learn about JUnit Basics, General Assertions, Number Equality, Object Equality, Array Equality, Hamcrest Assert that options, Testing Exceptions, Testing Collections, Custom Matcher using assert that, Testing with rules and much more. JUnit is a Regression Testing Framework used by developers to implement unit testing in Java, accelerate programming speed and increase the quality of code.
COURSE OBJECTIVESUpon successful completion of the course, the learner will be able to understand:
A JUnit test is a method contained in a class which is only used for testing. This is called a Test class. To define a certain method as a test method, annotate it with the @Test annotation. Sometimes it may happens that our code is not completely ready while running a test case. As a result, the test case fails. In this session, let us see some basic JUnit tests and how to manage failures using @Ignore annotation.
Assert is a method useful in determining Pass or Fail status of a test case, The assert methods are provided by the class org.junit.Assert which extends java.lang.Object class.There are various types of assertions like Boolean, Null, Identical etc. In this session, let us understand more about assertions in JUnit.
The assertThat is one of the JUnit methods from the Assert object that can be used to check if a specific value match to an expected one using hamcrest matcher. Hamcrest is a framework for software tests. Hamcrest allows checking for conditions in your code via existing matchers classes. It also allows you to define your custom matcher implementations. In this session, we would be understanding how to use Hamcrest matchers in JUnit with the assertThat statement.
Hamcrest provides matchers for inspecting Collections such as list, map, etc., In this tutorial, we are going to explore the Hamcrest Collection API and learn how we can write better and more maintainable unit tests with it.
JUnit provides an option of tracing the exception handling of code. You can test whether the code throws a desired exception or not. The expected parameter is used along with @Test annotation. Parameterized tests allow a developer to run the same test over and over again using different values. In this session, Let us see @Test(expected) in action and also we would be understanding about parameterized test in JUnit.
As well as built-in matchers, Hamcrest also provides support for creating custom matchers. Assume class provides a set of methods useful for stating assumptions about the conditions in which a test is meaningful. In this session, we’ll take a closer look at how to create and use a custom matcher and we would also understand about Assume class in JUnit.
A test fixture is a fixed state of a set of objects used as a baseline for running tests. The purpose of a test fixture is to ensure that there is a well known and fixed environment in which tests are run so that results are repeatable.In JUnit, the order of test method execution is not so unpredictable anymore, by default the order though not specified will be deterministic for every run. The order can further be enforced by adding a new annotation @FixMethodOrder to the test class with different values.@Rule allows us to intercept method before and after the actual run of the method.In this session, we are going to understand about test fixtures, test ordering, and how to enhance a test using @Rule in JUnit.
You can opt for the following courses once you complete your ongoing course
E-Box is a Technology Enabled Active Learning and
Assessment platform for technology and engineering
domains apart from the basic LMS components like
quizzes, assignments, lesson components.