concept JUnit in category junit

appears as: JUnit, JUnit, The JUnit, JUnit
JUnit in Action

This is an excerpt from Manning's book JUnit in Action.

If you recognize the names Erich Gamma and Kent Beck, that’s for a good reason. Gamma is one of the Gang of Four who gave us the now-classic Design Patterns book.[3] Beck is equally well known for his groundbreaking work in the software discipline known as Extreme Programming (www.extremeprogramming.org).JUnit quickly became the de facto standard framework for developing unit tests in Java. Today, JUnit (https://junit.org) is open source software hosted on GitHub, with an Eclipse Public License. And the underlying testing model, known as xUnit, is on its way to becoming the standard framework for any language. xUnit frameworks are available for ASP, C++, C#, Eiffel, Delphi, Perl, PHP, Python, REBOL, Smalltalk, and Visual Basic—to name just a few.

Figure 3.4 The monolithic architecture of JUnit 4: a single JAR file
Listing 4.1 The JUnit 4 Maven dependency
<dependencies>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>test</scope>
    </dependency>
</dependencies>

In this chapter, we will analyze and compare the main IDEs that can be used to develop Java applications tested with the help of JUnit 5. An integrated development environment (IDE) is an application that provides software development facilities for computer programmers. Java IDEs are tools that let us write and debug Java programs more easily.

JUnit in Action, Second Edition

This is an excerpt from Manning's book JUnit in Action, Second Edition.

JUnit (http://www.junit.org) is open source software, released under IBM’s Common Public License Version 1.0 and hosted on SourceForge. The Common Public License is business friendly: people can distribute JUnit with commercial products without a lot of red tape or restrictions.

JUnit quickly became the de facto standard framework for developing unit tests in Java. The underlying testing model, known as xUnit, is on its way to becoming the standard framework for any language. There are xUnit frameworks available for ASP, C++, C#, Eiffel, Delphi, Perl, PHP, Python, REBOL, Smalltalk, and Visual Basic—to name a few!

1.6. Testing with JUnit

JUnit has many features that make it easy to write and run tests. You’ll see these features at work throughout this book:

Without further ado, let’s turn to listing 1.4 and see what the simple Calculator test looks like when written with JUnit.

Listing 1.4. The JUnit CalculatorTest program

This is a much simpler test; let’s walk through it. At , we start by defining a test class. The only restriction is that the class must be public; we can name it whatever we like. It’s common practice to end the class name with Test. Notice also that in contrast to JUnit 3 where we needed to extend the TestCase class, this requirement has been removed in JUnit 4.

At , we mark the method as a unit test method by adding the @Test annotation.[6] A best practice is to name test methods following the testXXX pattern. JUnit doesn’t have method name restrictions. You can name your methods as you like; as long as they have the @Test annotation, JUnit will execute them.

Listing A.2. Test method annotations in JUnit 4.x
@Test public void substract () { assertEquals(2, 5-3); }