Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 15 Next »

Draft

Icon

I am in the process of researching and documenting all the current solutions offline and tying together a more complete proposal that matches the criteria below. - Brett 26/Dec/07

Overview

There are currently a number of solutions for testing plugins - both in terms of unit testing and integration testing. This has resulted in a confusing situation where plugins can be tested in multiple different ways, and there are no clear instructions for a new plugin author in how to test their plugins.

The objective of this document is to assess all the current approaches, and their positives and negatives, and to provide a baseline for discussion about the various approaches. It will attempt to identify overlap and make proposals to reduce duplication and confusion. It will also attempt to document how to write integration tests for your plugin, depending on your objectives. It will not attempt to propose a single-replacement solution - as there are likely good reasons to have different types of testing, and a separation of different techniques into different plugins (though deprecation of some libraries or techniques to reduce duplication may be necessary).

Available Solutions

Unit Testing

Definition: This is traditional unit testing - it takes no consideration for the fact that it is a Maven plugin, and tests the code itself.

  1. maven-plugin-testing-harness: This library provides assistance for plugin testing by pre-constructing the Plexus components, providing stub objects for Maven functionality such as projects, and populating fields from an XML file that resembles the plugin configuration in the POM.
  2. standard JUnit testing: MOJOs written in Java can be tested using JUnit as standard Java objects (possibly using a mock framework to mock the Maven functionality such as projects). For non-Java MOJOs, a corresponding test framework may be used for that language but the same principles apply. Using the PlexusTestCase can also give some of the instantiation assistance of the testing harness without the stubs.

Integration Testing

Definition: Integration testing for plugins is checking that a plugin works with the Maven framework libraries in a given situation, but does not do and end-to-end functional test of a Maven project.

Functional Testing

Definition: Functional testing for plugins is running an entire Maven build that utilises a given plugin and verifies the output of the build process.

Smoke Testing

Definition: A form of functional test that would be run in the integration testing phases and checks base functionality for sanity.

Performance Testing

Definition: Performance testing is a specialised form of acceptance testing.

Requirements

Key

CIT

maven-component-it-plugin

CIJ

maven-component-it-plugin with Java wrappers generated

INV

maven-invoker-plugin

ITP

maven-it-plugin

VER

maven-verifier

STY

shitty-maven-plugin

PTH

maven-plugin-testing-harness

VRP

maven-verifier-plugin (separate from verifier)

Comparison Matrix

 

CIT

CIJ

INV

ITP

VER

STY

PTH

VRP

Notes

Runs with Surefire

(error)

(tick)

(error)

(error)

(tick)

(error)

(tick)

N/A

 

Generates JUnit XML

(error)

(tick)

(error)

(error)

(tick)

(error)

(tick)

N/A

 

Can measure coverage using standard techniques

(error)

(tick)

(error)

(error)

(tick)

(error)

(tick)

N/A

 

Can be used for unit testing

(error)

(error)

(error)

(error)

(error)

(error)

(tick)

(tick)

 

Can be used for integration testing

(error)

(error)

(error)

(tick)

(error)

(error)

(error)

(tick)

 

Can be used for functional testing

(tick)

(tick)

(tick)

(tick)

(tick)

(tick)

(error)

(tick)

 

Has a non-snapshot release

(tick)

(tick)

(tick)

(tick)

(tick)

(tick)

(tick)

(tick)

 

Has a non-alpha release

(error)

(error)

(tick)

(error)

(tick)

(error)

(error)

(tick)

 

Has an archetype

(error)

(error)

(error)

(error)

(tick)

(error)

(error)

(error)

 

Test without installation

(tick)

(tick)

(error)

(error)

(error)

(tick)

(tick)

N/A

 

Run tests against multiple versions

(error)

(error)

(error)

(error)

(tick)

(error)

(error)

N/A

 

Forked Maven

N/A

N/A

(tick)

(error)

(tick)

(tick)

(error)

N/A

 

Embedded Maven

N/A

N/A

(error)

(tick)

(error)

(error)

(error)

N/A

 

Beanshell support

N/A

N/A

(tick)

(error)

(error)

(error)

(error)

(error)

 

Groovy support

N/A

N/A

(error)

(error)

(error)

(tick)

(error)

(error)

 

Suite setup steps

N/A

N/A

(tick)

(error)

(tick)

(tick)

(tick)

(error)

 

Suite teardown steps

N/A

N/A

(tick)

(error)

(error)

(tick)

(tick)

(error)

 

Suite verification steps

N/A

N/A

(tick)

(error)

(tick)

(tick)

(tick)

(tick)

 

Cleans up logs, targets

N/A

N/A

(error)

(error)

(error)

(tick)

N/A

N/A

 

Does not pollute source tree on execution

(error)

(error)

(error)

(error)

(tick)

(error)

(tick)

N/A

 

Does not leave artifacts in the local repository

(tick)

(tick)

(error)

(error)

(error)

(tick)

N/A

N/A

 

Does not use the local repository

(tick)

(tick)

(error)

(error)

(error)

(error)

N/A

N/A

This is a concurrency issue if it uses the same location.

Does not use the temporary directory

(error)

(error)

(tick)

(tick)

(tick)

(tick)

(tick)

N/A

This is a concurrency issue if it uses the same location.

Isolated from user's environment/settings

(error)

(error)

(error)

(error)

(error)

(error)

(tick)

N/A

 

Able to run from the IDE

(error)

(tick)

(error)

(error)

(tick)

(error)

(tick)

N/A

 

Able to run offline (unless plugin requires it)

(tick)

(tick)

(tick)

(tick)

(error)

(tick)

(error)

N/A

 

Offline by default

(error)

(error)

(error)

(error)

(error)

(error)

(error)

N/A

 

Can be used for testing non-Maven things

(tick)

(tick)

(error)

(error)

(error)

(error)

(error)

(tick)

 

Can be used for Maven testing

(tick)

(tick)

(tick)

(tick)

(tick)

(tick)

(error)

(tick)

 

Can be used for plugin testing

(tick)

(tick)

(tick)

(tick)

(tick)

(tick)

(tick)

(tick)

 

Can be used for report plugin testing

(tick)

(tick)

(tick)

(error)

(error)

(tick)

(tick)

(error)

 

Tests plugin annotations

N/A

N/A

(tick)

(tick)

(tick)

(tick)

(error)

(error)

 

Able to run a single test

N/A

N/A

(tick)

(error)

(tick)

(tick)

(tick)

N/A

 

Able to run a regex set of tests

N/A

N/A

(tick)

(error)

(error)

(error)

(error)

N/A

 

Able to run a suite of tests

N/A

N/A

(tick)

(tick)

(tick)

(tick)

(tick)

N/A

 

Able to drop-in an IT easily from a user submission

(tick)

(error)

(tick)

(tick)

(error)

(tick)

N/A

N/A

 

Able to run in a separate project

(tick)

(tick)

(tick)

(tick)

(tick)

(tick)

N/A

N/A

 

Able to run in the same project

(error)

(error)

(error)

(error)

(error)

(tick)

N/A

N/A

 

Able to compile custom sources

N/A

N/A

N/A

N/A

N/A

N/A

(error)

N/A

 

Able to add custom dependencies

N/A

N/A

N/A

N/A

N/A

N/A

(error)

N/A

 

Provides stub factories for creating Maven objects

N/A

N/A

N/A

(error)

N/A

(error)

(tick)

N/A

 

Provides alternate remote repository handling

(error)

(error)

(error)

(error)

(error)

(error)

(error)

N/A

 

Fast execution

N/A

N/A

(error)

(tick)

(error)

(error)

(tick)

N/A

 

Able to stage local repository state

(tick)

(tick)

(error)

(error)

(error)

(error)

(error)

N/A

 

Capture Maven exit code and exceptions

N/A

N/A

(tick)

(tick)

(tick)

(tick)

N/A

(error)

 

Maven home is configurable

N/A

N/A

(tick)

(error)

(tick)

(error)

N/A

N/A

 

Configurable Maven settings file

N/A

N/A

(tick)

(error)

(tick)

(tick)

N/A

N/A

 

Configurable individual Maven settings

N/A

N/A

(tick)

(error)

(error)

(error)

N/A

N/A

 

Configurable working directory

N/A

N/A

(tick)

(error)

(error)

(error)

(error)

N/A

 

Configurable input/output handlers for Maven

N/A

N/A

(tick)

(error)

(error)

(error)

(error)

N/A

 

Configurable Maven logger

N/A

N/A

(tick)

(error)

(error)

(error)

(error)

N/A

 

Can select which projects to run (include/exclude)

(tick)

(tick)

(tick)

(tick)

(error)

(tick)

(error)

N/A

 

Able to run Maven in batch mode

N/A

N/A

(tick)

(error)

(tick)

(error)

(error)

N/A

 

Able to run Maven in debug mode

N/A

N/A

(tick)

(error)

(error)

(tick)

(error)

N/A

 

Able to inherit shell environment

N/A

N/A

(tick)

N/A

(error)

(error)

N/A

N/A

 

Pass goals to run Maven with

N/A

N/A

(tick)

(tick)

(tick)

(tick)

N/A

N/A

 

Pass goals to run Maven with in a file

N/A

N/A

(tick)

(tick)

(tick)

(tick)

N/A

N/A

 

Interpolate goals to run Maven with

N/A

N/A

(tick)

(error)

(error)

(error)

N/A

N/A

 

Pass properties to run Maven with

N/A

N/A

(tick)

(error)

(tick)

(tick)

N/A

N/A

 

Pass properties to run Maven with in a file

N/A

N/A

(tick)

(error)

(tick)

(tick)

N/A

N/A

 

Interpolate properties to run Maven with

N/A

N/A

(tick)

(error)

(error)

(error)

N/A

N/A

 

Pass profiles to run Maven with

N/A

N/A

(tick)

(error)

(error)

(error)

N/A

N/A

 

Pass profiles to run Maven with in a file

N/A

N/A

(tick)

(error)

(error)

(error)

N/A

N/A

 

Pass flags to run Maven with

N/A

N/A

(error)

(error)

(error)

(tick)

N/A

N/A

 

Pass flags to run Maven with in a file

N/A

N/A

(error)

(error)

(error)

(tick)

N/A

N/A

 

Able to run tests in parallel

N/A

N/A

(error)

(error)

(error)

(tick)

N/A

N/A

Duplicates Surefire TestNG configuration.

Able to timeout tests run in parallel

N/A

N/A

(error)

(error)

(error)

(tick)

N/A

N/A

Duplicates Surefire TestNG configuration.

Supports ANSI output

N/A

N/A

(error)

(error)

(error)

(tick)

(error)

(error)

Should be integrated into Surefire.

Can ignore failures

N/A

N/A

(error)

(error)

(error)

(tick)

(tick)

(error)

Duplicates Surefire configuration.

Can skip execution

N/A

N/A

(error)

(error)

(error)

(tick)

(tick)

(error)

Duplicates Surefire configuration.

Suggested Use

TODO

Icon

To be completed once matrix is complete and examples have been generated to decide direction

Proposals

TODO

Icon

To be completed based on suggested use and missing needs

Notes

  • IT plugin has grown out of date
  • verifier is stable - used in Maven ITs and Surefire ITs
  • invoker is stable
  • plugin testing harness is stable but alpha
  • plugin testing tools/component IT plugin is stable but alpha

John says: "I'm hoping to converge the tools
we're using in the core ITs with those in the maven-component-test-plugin
(used to be maven-plugin-test-plugin), and the maven-invoker-plugin, and
arrive at some single solution (a plugin) that we can use everywhere...but I
haven't even been able to come up with a unified feature list yet."

Plugin Testing Tool documentation discusses the need for a different local repository (need could be reviewed by improving local repo mechanism, so keep that functionality separate). Incorporate doc into final solution. Note disagreement with "test suite maintenance" - integration tests != functional tests, and both should be well designed, not easily adapted from users (though easily executing users's tests and helping them construct well designed tests is a better goal). Note: Not much different between component tool and plugin tool

Test without installation (c.f. staging and unstaging of plugin - implications for concurrent execution) - to Not pollute the local repository (how about using a timestamped version?

Invoker Plugin has a lot of logic in one mojo, and duplicates other plugins

IT plugin is now duplicated with invoker

Plugin Management Plugin seems roughly equivalent to the component IT plugin but for general use. Could be irrelevant under local repository changes.

Test Tools re a library used by component IT - does a couple of file manipulations for tests.

Verifier duplicates a lot of utilities

Usages

Assembly Plugin

Runs within src/it, cleans within there
Functional tests are not included in the POM.

Dependency Plugin

Integration tests are not integrated - set up as separate test projects.

Surefire Plugin

Using the separate project with standard Maven IT practices (these are really functional tests?)

Project Info Reports

Does HTMLUnit tests on the output - manually constructs the mojo like a regular IT, uses plugin testing harness.
Quite slow, though.
Adjustments should be revised.

Other Executors

Some other projects implement Maven executors (eg the release plugin). These should simply be migrated to the invoker (adding in any additional functionality as needed) rather than seeking a unified solution at this point. It is unrelated to testing.

Resources

Discussions:

Plugins and libraries for testing:

  • No labels