trivago / cucable-plugin

Maven plugin that simplifies running Cucumber scenarios in parallel.
Apache License 2.0
115 stars 42 forks source link

Generate runners and features in maven target #17

Closed bischoffdev closed 6 years ago

bischoffdev commented 7 years ago

http://www.mojohaus.org/build-helper-maven-plugin/usage.html

amaravathi commented 6 years ago

correct me if I am wrong, either way directories are configurable , so we can use some thing like ${project.build.directory}/parallel/features and ${project.build.directory}/parallel and files will be in target folder

bischoffdev commented 6 years ago

That's true but they won't be considered test sources. And since the runners have to be compiled it is not that easy. If you get it to work like you said I would be happy if you let me know so I can add it to the documentation.

amaravathi commented 6 years ago

Thank you laxersaz, as you rightly said those files cant be part of sources to get compiled .

Considering that in mind, have tweaked pom file to get test-sources comiple, and make .classes avaialble to run the test cases .

And here is my cucable.template and plugin details cucable.template

@RunWith(Cucumber.class) @CucumberOptions( monochrome = false, features = {"target/parallel/features/[FEATURE_FILE_NAME].feature"}, format = {"json:target/cucumber-report/[FEATURE_FILE_NAME].json"}, strict = false, dryRun = false, glue={"com.test.demostore.stepdefinition"}, tags= {"@SmokeTest"} ) public class [FEATURE_FILE_NAME] { }

      <plugins>
       <plugin>
            <groupId>com.trivago.rta</groupId>
            <artifactId>cucable-plugin</artifactId>
            <version>0.0.9</version>
            <executions>
                <execution>
                    <id>parallel</id>
                    <phase>generate-test-resources</phase>
                    <goals>
                        <goal>parallel</goal>
                    </goals>
                    <configuration>
                        <sourceRunnerTemplateFile>src/test/resources/parallel/cucable.template
                        </sourceRunnerTemplateFile>

                        <!-- process all features in the given directory --> 
                         <sourceFeatures>src/test/resources/features</sourceFeatures> 

                        <!-- process a specific file in the given directory -->
                        <!--<sourceFeatures>src/test/resources/features/testfeature/MyTest1.feature</sourceFeatures>-->

                        <!-- process a specific file and a specific line number in the given directory -->
                        <!--<sourceFeatures>src/test/resources/features/testfeature/MyTest1.feature:12</sourceFeatures>-->

                        <generatedFeatureDirectory>${project.build.directory}/parallel/features</generatedFeatureDirectory>

                        <generatedRunnerDirectory>${project.build.directory}/parallel/runners</generatedRunnerDirectory>
                        <numberOfTestRuns>1</numberOfTestRuns>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>3.0.0</version>
            <executions>
              <execution>
                <id>add-test-source</id>
                <phase>generate-test-sources</phase>
                <goals>
                  <goal>add-test-source</goal>
                </goals>
                <configuration>
                  <sources>
                    <source>${project.build.directory}/parallel/runners</source>                        
                  </sources>
                </configuration>
              </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>                
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                    </goals>
                    <configuration>
                        <forkCount>2</forkCount>                            
                    </configuration>
                </execution>
            </executions>
        </plugin>
 <plugins>
bischoffdev commented 6 years ago

That's cool, @amaravathi ! Thanks a lot for your detailed post. I will try that for sure and think about a good way to integrate it into Cucable if possible.

bischoffdev commented 6 years ago

This will be moved to the main README.md file for the next version 0.1.7

bischoffdev commented 6 years ago

I rewrote the readme file and included the description on how to generate features and runners in Maven target. Thanks again for your help, @amaravathi !

jaydeepbasu commented 6 years ago

I recently came across Cucable plugin and it works great for me, but I am facing one problem, that is how to attach screenshot in the report against any particular step.