Comments have been closed on this page. Please use AppMon & UEM Open Q & A forum for questions about this plugin.


  • Download the Maven plugin from the Automation Library (Ant, Maven) for Dynatrace download page
  • Import the Maven plugin into your local repository using the following command:


  1. In the properties section of the pom.xml, you can define Dynatrace-related properties that are used by the Dynatrace plugin. You can use this to define default properties that are then overwritten in the actual plugin configuration (for example, if you use multiple profiles for unit and performance tests):

  2. As a prerequisite to use the Dynatrace plugin in your Maven build, add a dependency to your pom.xml:

    Dependency in Maven
  3. Before you run your tests (JUnit, TestNG, NUnit), use the startTest goal of the Dynatrace plugin to register a new test run on the Dynatrace Server  and pass additional metadata like the major/minor version. This way, the Dynatrace Server is able to identify PurePaths that originate in the same test run and allows you to perform parallel test runs. In Maven, you have two ways to achieve this: You can attach the plugin execution to a lifecycle phase that's happening before the tests are executed (recommended), or you can manually invoke to appropriate plugin goal (only for Dynatrace versions prior to 6.1).

    1. Attaching plugin execution to lifecycle phase: This is the recommended of usage way as it guarantees that the startTest goal is always invoked when tests are run. In order to identify the correct phase to attach to you have to know which tests you are executing as Maven distinguishes between unit tests (executed by the Surefire plugin), and integration tests (executed by the Failsafe plugin), and of course it's also possible to use Dynatrace for both phases.
      What is the difference between these plugins? The Surefire plugin will fail the build immediately when a test fails, while the Failsafe plugin will execute all tests regardless of any failure, and then look at the build results and fail the build if necessary builds (also see the Maven documentation). This means that with the Surefire plugin, a failing test will cause the build to stop in the test phase, while with Failsafe it is guaranteed to pass through the
      post-integration-test phase and stop in the verify phase if necessary.
      If you want to use Dynatrace to monitor your unit tests executed by Surefire, take a look at the following configuration snippet:

      dynaTrace Configuration for unit tests (using Surefire)

      Monitoring tests run by Failsafe works as follows:

      dynaTrace Configuration for integration tests (using failsafe)
    2. Manually invoking Dynatrace goals (for Dynatrace versions prior to 6.1): You can also manually execute the Dynatrace plugin goals, for example as follows:

  4. And that's it!  You can continue with your build script as you usually would, for example with building an HTML report of JUnit results and bundling up artifacts.

  • No labels