Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine reports in multi-module maven setup #86

Open
alwyn opened this issue Nov 4, 2016 · 8 comments
Open

Combine reports in multi-module maven setup #86

alwyn opened this issue Nov 4, 2016 · 8 comments

Comments

@alwyn
Copy link

alwyn commented Nov 4, 2016

Hi,

As an enhancement, could we configure spock-reports to generate a main report for a multi-module project?

It could either itself contain all the results or link to the results of sub-modules.

In my case the need arises because I am slowly migrating tests over to spock and they are strewn all over the show at the moment.

@renatoathaydes
Copy link
Owner

Hi.

I've done something like this at work... But doing so requires an external tool, like a Maven/Gradle plugin because, as an extension of Spock, spock-reports is limited to one module (in my case, I wrote a Groovy script that gets called by GMaven from Maven).

spock-reports exposes lots of information about all Specifications it ran in a json file (easy to parse). Look at the spock-reports directory, there should be a file called aggregated_report.json. This is meant to provide the information for external tools to build a full report for a multi-module project.

It looks like this:

{
  "com.acme.MySpec": {
    "executedFeatures": [
      "Regex can replace value in String"
    ],
    "ignoredFeatures": [],
    "stats": {
      "failures": 0,
      "errors": 1,
      "skipped": 0,
      "totalRuns": 1,
      "successRate": 0.0,
      "time": 106
    }
  },
  "com.acme.OtherSpecification": {
    "executedFeatures": [
      "Some other feature"
    ],
    "ignoredFeatures": [],
    "stats": {
      "failures": 0,
      "errors": 1,
      "skipped": 0,
      "totalRuns": 1,
      "successRate": 0.0,
      "time": 135
    }
  },
  ...
}

Linking to the individual reports is very easy: just copy the name of the spec (eg. com.acme.MySpec in the example above) and add .html to it... the html reports are all located in the same directory as this json file, so an absolute link it trivial to create.

The general report for the module is called index.html, as you probably know.

@sskjames
Copy link

Hi @renatoathaydes do you think providing an option to prefix index.html with the module name is a good option?

@renatoathaydes
Copy link
Owner

@sskjames something like that could work... I guess we just need to try and see what is needed.

@sskjames
Copy link

That's great. Thank you very much for creating this extension.

@renatoathaydes
Copy link
Owner

@sskjames my pleasure :) it's good to know people appreciate it.

@mfriedenhagen
Copy link
Contributor

Just a hint: for one multi-module project I just specified the output-dir to point to the parent project. Using the following in a profile of the project parent-pom, this stuff is only included when there are spock tests at all:
You need to override the configuration for surefire and failsafe, the index page shows all tests.

    <profiles>
        <profile>
            <id>spock-reports</id>
            <activation>
                <file>
                    <exists>src/test/groovy</exists>
                </file>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>com.athaydes</groupId>
                    <artifactId>spock-reports</artifactId>
                    <version>1.5.0</version>
                    <scope>test</scope>
                    <!-- this avoids affecting your version of Groovy/Spock -->
                    <exclusions>
                        <exclusion>
                            <groupId>*</groupId>
                            <artifactId>*</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
            </dependencies>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-surefire-plugin</artifactId>
                            <configuration>
                                <systemProperties>
                                    <com.athaydes.spockframework.report.showCodeBlocks>true</com.athaydes.spockframework.report.showCodeBlocks>
                                    <com.athaydes.spockframework.report.outputDir>${user.dir}/target/spock-reports</com.athaydes.spockframework.report.outputDir>
                                </systemProperties>
                            </configuration>
                        </plugin>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-failsafe-plugin</artifactId>
                            <configuration>
                                <systemProperties>
                                    <com.athaydes.spockframework.report.outputDir>${user.dir}/target/spock-reports</com.athaydes.spockframework.report.outputDir>
                                </systemProperties>
                            </configuration>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>
    </profiles>

@ntung
Copy link

ntung commented Sep 17, 2018

I would know the status of this work. I am facing the same issue that the application has a lot of plugins which are submodules. Spock report could not be generated into the target folder of those modules. How come?

@renatoathaydes
Copy link
Owner

@ntung what do you mean? Multi-module Maven module reports should work... This issue is about combining multiple reports from sub-modules into one... Is that what you say is not working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants