List implemented Junit tests

This Mojo enables one to list as a Json file the available implemented tests. In order to do so one only needs to run the following command :

mvn clean compile test-compile org.squashtest.ta.galaxia:squash-tf-junit-runner-maven-plugin:1.0.0-RELEASE:list

The command is structured as follows

  • mvn : launch Maven
  • clean : (Optional) One of Maven default goals that enables one to clean everything that has been previously build by Maven.
  • compile : One of Maven default goals that enables one to compile code that is stored in src/main.
  • test-compile : One of Maven default goals that enables one to compile code that is stored in src/test.
  • org.squashtest.ta.galaxia:squash-tf-junit-runner-maven-plugin:1.0.0-RELEASE:list : the actual listing Mojo provided by the Squash TF Java Junit Runner. It lists all Junit tests that can be discovered (in the Junit sense) in the code compiled during the “compile” and “test-compile” phases.

The result should be a Json file named testTree.json located at target/squashTA/test-tree. It is a simple JavaScript table listing available test grouped by “ecosystems”. Ecosystem naming follows the convention explained in the Junit tests reference scheme section above.

‘list’ goal with Metadata

If there are metadata in the current test project, the goal “list” searches and checks if all metadata in this JUnit project respect the conventions for writing and using Squash TF metadata. (See Metadata in JUnit runner for more information about Metadata syntax conventions)

The goal will check through the project, collect all the metadata error(s) if any and lead to the FAILURE. Otherwise, a SUCCESS result will be obtained.

Metadata error(s), if found, will be grouped by test names.

List build FAILURE

Listing test JSON report with Metadata

If the build is successful, the generated report (JSON file) will contain the metadata associated with each of the test scripts.

{
        "timestamp": "2019-09-23T14:56:24.761+0000",
        "name": "tests",
        "contents": [{
                    "name": "maven.test.bundle:com.example.project.CalculatorTest2",
                    "contents": [{
                        "name": "testAdd()",
            "metadata": {},
            "contents": null
        }, {
            "name": "This is my test",
            "metadata": {
                "key1..": null
            },
            "contents": null
        }, {
            "name": "testAddWithTFMetadata2()",
            "metadata": {
                "key2": ["value2"]
            },
            "contents": null
        }, {
            "name": "testAddWithTFMetadata3()",
            "metadata": {
                "Key3-": null,
                "key_4": ["value4"],
                "Key53": ["value4-","value4-"]
            },
            "contents": null
        }
    ]
}

Note

To ignore thoroughly metadata during the listing process as well as in the report, insert tf.disableMetadata property after the goal “list”.

mvn clean compile test-compile org.squashtest.ta.galaxia:squash-tf-junit-runner-maven-plugin:1.0.0-RELEASE:list -Dtf.disableMetadata=true

or as a property in the pom.xml file

<properties>
        <tf.disableMetadata>true</tf.disableMetadata>
</properties>