temyers / cucumber-jvm-parallel-plugin

Maven plugin to help running Cucumber features in parallel
Apache License 2.0
129 stars 121 forks source link

Have you try this in the runnerclasses extends another class ? #122

Closed gaponte1985 closed 7 years ago

gaponte1985 commented 7 years ago

package cukes.runners;

import cucumber.api.CucumberOptions; import cucumber.api.junit.Cucumber; import org.junit.runner.RunWith; import utilities.hooks.BaseRunner;

@RunWith(Cucumber.class) @CucumberOptions(strict = true, format = {"junit:target_junit/cucumber.xml"}, features = {"/src/test/resources/features/google/"}, plugin = {"json:target/reports/output/1.json", "pretty"}, monochrome = true, tags = {"@Web"}, glue = { "utilities.hooks", "cukes.steps.frameworkshakeout.Web" })

public class Google extends BaseRunner {}

mpkorstanje commented 7 years ago

The TestNG runner extends another class. You can use a custom template if you want to extend your own class.

gaponte1985 commented 7 years ago

I want to used only Junit

mpkorstanje commented 7 years ago

You can use a custom runner with Junit and extend another class. The TestNG runner is an example of doing such a thing.

gaponte1985 commented 7 years ago

parse("/array.java.vm")

if ($packageName)

package $packageName;

end

import cucumber.api.CucumberOptions; import utilities.hooks;

@CucumberOptions( strict = $strict, features = {"$featureFile"}, plugin = #stringArray($plugins), monochrome = ${monochrome},

if(!$featureFile.contains(".feature:") && $tags)

        tags = #stringArray($tags),
#end
    glue = #stringArray($glue))

public class $className extends BaseRunner { } I have something like this does this make sense?

gaponte1985 commented 7 years ago

so is creating the file with the extends but not running

gaponte1985 commented 7 years ago

LAMU02TC0F2GTFM:com.uhc.coretestautofrmwk gaponte2$ mvn test [INFO] Scanning for projects... [INFO]
[INFO] ------------------------------------------------------------------------ [INFO] Building QAAutomation 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ QAAutomation --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 2 resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ QAAutomation --- [INFO] Changes detected - recompiling the module! [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 24 source files to /Users/gaponte2/IdeaProjects/bff-core/com.uhc.coretestautofrmwk/target/classes [INFO] [INFO] --- cucumber-jvm-parallel-plugin:4.1.0:generateRunners (generateRunners) @ QAAutomation --- [INFO] Adding /Users/gaponte2/IdeaProjects/bff-core/com.uhc.coretestautofrmwk/target/generated-test-sources/cucumber to test-compile source root [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ QAAutomation --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 26 resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ QAAutomation --- [INFO] Changes detected - recompiling the module! [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 20 source files to /Users/gaponte2/IdeaProjects/bff-core/com.uhc.coretestautofrmwk/target/test-classes [INFO] [INFO] --- maven-surefire-plugin:2.20:test (default-test) @ QAAutomation --- [INFO] [INFO] ------------------------------------------------------- [INFO] T E S T S [INFO] ------------------------------------------------------- [INFO] Running cukes.runners.Parallel01IT [INFO] Running cukes.runners.Parallel02IT [INFO] Running cukes.runners.Parallel03IT [INFO] Running cukes.runners.Parallel04IT [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.836 s - in cukes.runners.Parallel01IT [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.786 s - in cukes.runners.Parallel02IT [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.817 s - in cukes.runners.Parallel03IT [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.719 s - in cukes.runners.Parallel04IT [INFO] [INFO] Results: [INFO] [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 5.211 s [INFO] Finished at: 2017-07-10T18:02:38-04:00 [INFO] Final Memory: 40M/422M [INFO] ------------------------------------------------------------------------ LAMU02TC0F2GTFM:com.uhc.coretestautofrmwk gaponte2$

gaponte1985 commented 7 years ago

I think is not creating the following folder target/cucumber-parallel

temyers commented 7 years ago

The files should be created under target/generated-test-sources/cucumber

The output suggests that the tests are being executed, but there it has not identified any valid tests.

[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running cukes.runners.Parallel01IT
[INFO] Running cukes.runners.Parallel02IT
[INFO] Running cukes.runners.Parallel03IT
[INFO] Running cukes.runners.Parallel04IT
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.836 s - in cukes.runners.Parallel01IT
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.786 s - in cukes.runners.Parallel02IT
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.817 s - in cukes.runners.Parallel03IT
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.719 s - in cukes.runners.Parallel04IT

Are you able to share your pom.xml?

gaponte1985 commented 7 years ago

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0
<groupId>com.uhc.coretestautofrmwk</groupId>
<artifactId>QAAutomation</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
    <!-- Needed for allure-maven-plugin to specify report version -->
    <allure.version>1.4.11</allure.version>
    <aspectj.version>1.7.4</aspectj.version>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.8.0</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.4.0</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-api</artifactId>
        <version>3.4.0</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-firefox-driver</artifactId>
        <version>3.4.0</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-support</artifactId>
        <version>3.4.0</version>
    </dependency>
    <dependency>
        <groupId>net.sourceforge.htmlunit</groupId>
        <artifactId>htmlunit</artifactId>
        <version>2.26</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-chrome-driver</artifactId>
        <version>3.4.0</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-ie-driver</artifactId>
        <version>3.4.0</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-safari-driver</artifactId>
        <version>3.4.0</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-edge-driver</artifactId>
        <version>3.4.0</version>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit-dep</artifactId>
        <version>4.11</version>
    </dependency>

    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>1.2.5</version>
    </dependency>
    <dependency>
        <groupId>org.fluentlenium</groupId>
        <artifactId>fluentlenium-cucumber</artifactId>
        <version>3.2.0</version>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>1.2.5</version>
    </dependency>

    <dependency>
        <groupId>net.masterthought</groupId>
        <artifactId>cucumber-reporting</artifactId>
        <version>3.7.0</version>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-picocontainer</artifactId>
        <version>1.2.5</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.9</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.11-beta3</version>
    </dependency>

    <dependency>
        <groupId>xerces</groupId>
        <artifactId>xercesImpl</artifactId>
        <version>2.8.0</version>

    </dependency>
    <dependency>
        <groupId>com.relevantcodes</groupId>
        <artifactId>extentreports</artifactId>
        <version>2.41.1</version>
    </dependency>

    <dependency>
        <groupId>com.saucelabs</groupId>
        <artifactId>sauce_junit</artifactId>
        <version>2.1.23</version>
    </dependency>
    <dependency>
        <groupId>com.saucelabs</groupId>
        <artifactId>sauce_java_common</artifactId>
        <version>2.1.23</version>
    </dependency>

    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>1.8.10</version>
    </dependency>

    <dependency>
        <groupId>com.github.mkolisnyk</groupId>
        <artifactId>cucumber-reports</artifactId>
        <version>1.0.7</version>
    </dependency>
    <dependency>
        <groupId>ru.yandex.qatools.allure</groupId>
        <artifactId>allure-cucumber-jvm-adaptor</artifactId>
        <version>1.5.1</version>
    </dependency>
    <dependency>
        <groupId>com.tngtech.java</groupId>
        <artifactId>junit-dataprovider</artifactId>
        <version>1.12.0</version>
    </dependency>

    <dependency>
        <groupId>javassist</groupId>
        <artifactId>javassist</artifactId>
        <version>3.12.1.GA</version>
    </dependency>
    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-api-easymock</artifactId>
        <version>1.7.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.github.mkolisnyk</groupId>
        <artifactId>cucumber-runner</artifactId>
        <version>1.0.8</version>
    </dependency>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.6</version>
    </dependency>
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-all</artifactId>
        <version>1.3</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.fluentlenium</groupId>
        <artifactId>fluentlenium-assertj</artifactId>
        <version>3.2.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>htmlunit-driver</artifactId>
        <version>2.25</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>xml-apis</groupId>
        <artifactId>xml-apis</artifactId>
        <version>1.4.01</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.fluentlenium</groupId>
        <artifactId>fluentlenium-core</artifactId>
        <version>3.2.0</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-remote-driver</artifactId>
        <version>3.4.0</version>
    </dependency>
    <dependency>
        <groupId>org.fluentlenium</groupId>
        <artifactId>fluentlenium-junit</artifactId>
        <version>3.2.0</version>
    </dependency>
    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-module-junit4</artifactId>
        <version>1.7.0</version>
    </dependency>
    <dependency>
        <groupId>com.github.ferstl</groupId>
        <artifactId>junit-testgroups</artifactId>
        <version>1.0.1</version>
    </dependency>
    <dependency>
        <groupId>com.jayway.restassured</groupId>
        <artifactId>rest-assured</artifactId>
        <version>2.9.0</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit5-engine</artifactId>
        <version>5.0.0-ALPHA</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>com.github.temyers</groupId>
            <artifactId>cucumber-jvm-parallel-plugin</artifactId>
            <version>4.1.0</version>
            <executions>
                <execution>
                    <id>generateRunners</id>
                    <phase>generate-test-sources</phase>

                    <goals>
                        <goal>generateRunners</goal>
                    </goals>
                    <configuration>
                        <glue>
                            <package>utilities.java.hooks</package>
                            <package>cukes.steps.frameworkshakeout.API</package>
                            <package>cukes.steps.frameworkshakeout.UI</package>
                        </glue>
                        <outputDirectory>${project.build.directory}/generated-test-sources/cucumber</outputDirectory>
                        <featuresDirectory>src/test/resources/features/google/</featuresDirectory>
                        <cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>
                        <plugins>
                            <plugin>
                                <name>json</name>
                            </plugin>
                            <plugin>
                                <name>com.example.CustomHtmlFormatter</name>
                                <extension>html</extension>
                            </plugin>
                        </plugins>
                        <monochrome>true</monochrome>
                        <strict>true</strict>
                        <!-- CucumberOptions.monochrome property -->
                        <monochrome>true</monochrome>
                        <tags>
                            <tag>@API, @Web</tag>
                        </tags>
                        <filterFeaturesByTags>true</filterFeaturesByTags>
                        <useTestNG>false</useTestNG>
                        <!-- The naming scheme to use for the generated test classes.  One of 'simple' or 'feature-title' -->
                        <namingScheme>simple</namingScheme>
                        <!-- The class naming pattern to use.  Only required/used if naming scheme is 'pattern'.-->
                        <namingPattern>Parallel{c}IT</namingPattern>
                        <!-- One of [SCENARIO, FEATURE]. SCENARIO generates one runner per scenario.  FEATURE generates a runner per feature. -->
                        <parallelScheme>SCENARIO</parallelScheme>
                        <!-- Specify a custom template for the generated sources (this is a path relative to the project base directory) -->
                        <!--                        <customVmTemplate>src/test/resources/cucumber-custom-runner.vm</customVmTemplate> -->
                        <customVmTemplate>src/test/resources/cucumber-testng-runner.java.vm</customVmTemplate>
                        <!-- Specify a custom package name for generated sources. Default is no package.-->
                        <packageName>cukes.runners</packageName>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.20</version>
            <configuration>
                <forkCount>10</forkCount>
                <reuseForks>false</reuseForks>
                <includes>
                    <include>**Parallel**IT**.class</include>
                </includes>
            </configuration>
        </plugin>
    </plugins>
</build>

gaponte1985 commented 7 years ago
screen shot 2017-07-10 at 9 59 10 pm

file are there but not running when i try to run by it self

cucumber.runtime.CucumberException: Couldn't load plugin class: com.example.CustomHtmlFormatter

temyers commented 7 years ago

The current plugin configuration contains the sample from the README copied verbatim. This is purely for documentation purposes only to describe all the possible values.

                            <plugin>
                                <name>json</name>
                            </plugin>
                            <plugin>
                                <name>com.example.CustomHtmlFormatter</name>
                                <extension>html</extension>
                            </plugin>
                        </plugins>

is obviously inappropriate.

All the configuration properties have sensible defaults (detailed in the README). So unless you need to customise it, the properties should not be required.

Please review your pom.xml to resolve the issues.

If the current documentation in the README is confusing or inadequate, please can you submit a pull request suggesting improvements.

gaponte1985 commented 7 years ago

ok does the plugin support new TestNGCucumberRunner(getClass()).runCukes() ?