concept NetBeans in category junit

appears as: NetBes, NetBes
JUnit in Action MEAP V06

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

  • Integration with popular tools such as Maven and Gradle, as well as popular integrated development environments (IDEs) such as Eclipse, NetBeans, and IntelliJ
  • 12.3  Using JUnit 5 with NetBeans

    NetBeans is an IDE that we can use to write code in several programming languages including Java. For brief NetBeans installation instructions, see appendix C.

    Figure 12.25 Executing all tests from inside NetBeans
    Figure 12.30 Running repeated tests from NetBeans

    When running the whole test suite from NetBeans, tagged tests are also run. The IDE does not provide the option to run only particular tagged tests. If you are running a Maven project, you have to make changes at the level of the pom.xml file, with the help of the Surefire plugin. This plugin is used during the test phase of a project to execute an application’s unit tests; it may filter some of the executed tests or generate reports. A possible configuration is shown in the following listing, including tests tagged with individual and excluding tests tagged with repository. We discussed the @Tag annotation in chapter 2.

    Listing 12.1 Possible filtering configuration for the Maven Surefire plugin
    <build>
       <plugins>
          <plugin>
              <artifactId>maven-surefire-plugin</artifactId>
              <version>2.22.2</version>
              <configuration>
                  <groups>individual</groups>                
                  <excludedGroups>repository</excludedGroups>                
              </configuration>
       </plugin>
       </plugins>
    </build>

    It is not possible to run tests directly with code coverage from NetBeans. We can do this with the help of JaCoCo, an open source toolkit for measuring and reporting Java code coverage. If you are running a Maven project, you have to make changes at the level of the pom.xml file, using JaCoCo. The configuration of the JaCoCo plugin is shown next.

    JUnit in Action, Second Edition

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

  • Integration with popular tools like Ant and Maven, and popular IDEs like Eclipse, NetBeans, IntelliJ, and JBuilder
  • D.3. JUnit integration with NetBeans

    This section serves as a reference guide to how to work with the NetBeans IDE and how to write, execute, and compose JUnit tests from within NetBeans.

    Figure D.10. Compilation problems with NetBeans

    These compilation problems are due to the fact that NetBeans, unlike Eclipse, explicitly keeps two separate directories: one for the source files and one for the test-source files. For each of these folders NetBeans keeps a different set of libraries to include in the classpath. As you see in the figure, NetBeans detects src\test\java as a source folder, and the source-folder classpath probably doesn’t contain the JUnit JAR file. To see all the libraries that are included in the classpath, right-click your project, choose Properties, and in the box that appears choose the Libraries tag from the left tree. As you will see, the Compile Tests tab contains the JUnit JAR, so indeed the compilation problems were caused by the fact that NetBeans recognizes the folder as a source folder and not as a source-test folder.

    sitemap

    Unable to load book!

    The book could not be loaded.

    (try again in a couple of minutes)

    manning.com homepage
    test yourself with a liveTest