Java: JUnit 4 Example

(Last Updated On: )

In this tutorial I will show you how to use JUnit 4 into your application. The next tutorial I will use this class with PowerMock.

Build Path

Ensure you have added JUnit 4 to your build path and that you are using Java 8.

Imports

import org.junit.Before;
import org.junit.Test;

Test Class

package ca.gaudreault.mytestapp;

import org.junit.Before;
import org.junit.Test;

public class AppTest {
	@Before
	public void setup() {
	}

	@Test
	public void myTest() {
	}
}

This was a very basic example of writing a unit test with JUnit 4. In future example I will build on this with PowerMock.

One thought on “Java: JUnit 4 Example”

Comments are closed.