JUnit 4 Template Class

Each time I want to create a JUnit test class, I take a look at an older one, copy it, then remove all of the specifics of the previous tests.

That isn't a good practice  :-)


So I've decided to do it once more, in order to create a template - a working JUnit class which doesn't do anything, just add your specific code you want to test and run along:

package org.chaiavi.TestJunit;

import java.io.IOException;
import org.junit.*;
import static org.junit.Assert.*;

public class TestJunit{
/** Use this method for all of the lines of code you want to run before the whole JUnit Class. */
@BeforeClass
    public static void unitSetup() throws Exception {

}
/** Use this method for all of the lines of code you want to run after the whole JUnit Class. */
@AfterClass
    public static void unitCleanup() throws Exception {
    } 
/** Use this method for all of the lines of code you want to run before each JUnit test. */
@Before
    public void methodSetup() throws Exception {
}
/** Use this method for all of the lines of code you want to run after each JUnit test. */
@After
    public void methodCleanup() throws Exception {
    } 
/** Use the Test annotation for each JUnit Test method. */
@Test
    public void runTest() {
}
}

Comments

Popular posts from this blog

Profiling Java @ 2019

Ant Explorer graphical Ant build tool

Shared/Pro/Managed Hosting for your site - which to choose ? (NO AFFILIATE LINKS!)