MoinMoin Logo
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

Navigation

  • Start
  • Sitemap
Revision 3 as of 2014-11-02 14:44:34
  • Java
  • JUnit

JUnit

A programmer-oriented testing framework for Java.

http://junit.org/

Annotations

  • @Before , public void setUp(){}
  • @Test , public void textAbc(){}
  • @After , public void tearDown(){}

Imports

   1 import static org.junit.Assert.assertEquals;
   2 import org.junit.Test;
   3 import org.junit.Ignore;
   4 import org.junit.runner.RunWith;
   5 import org.junit.runners.JUnit4;

Inclusion classes

http://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html

By default, the Surefire Plugin will automatically include all test classes with the following wildcard patterns:

"**/Test*.java" - includes all of its subdirectories and all java filenames that start with "Test".
"**/*Test.java" - includes all of its subdirectories and all java filenames that end with "Test".
"**/*TestCase.java" - includes all of its subdirectories and all java filenames that end with "TestCase".

Import methods

   1  import static org.junit.Assert.*;
   2   //  ...
   3   assertEquals(...);

Maven dependency

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.11</version>
</dependency>  

On a Maven project the tests may be located inside /src/test/java/ so they are integrated in the main artifact generated by Maven.

  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01