TNG / junit-dataprovider

A TestNG like dataprovider runner for JUnit with many additional features
Apache License 2.0
246 stars 164 forks source link

Maven command line doesn't recognize the automation scripts #126

Closed Harikahema1 closed 4 years ago

Harikahema1 commented 4 years ago

Trying to execute automation scripts build on cucumber,java,junit through Maven command line


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">

<modelVersion>4.0.0</modelVersion>
<groupId>com.name</groupId>
<artifactId>HTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>8</source>
                <target>8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M3</version>
        </plugin>
    </plugins>
</build>
<name>MTest</name>
<url>http://maven.apache.org</url>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
    <repository>
        <id>central</id>
        <name>Maven repository</name>
        <url>https://repo1.maven.org/maven2</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>net.lightbody.bmp</groupId>
        <artifactId>browsermob-core</artifactId>
        <version>2.1.5</version>
    </dependency>

    <dependency>
        <groupId>net.lightbody.bmp</groupId>
        <artifactId>browsermob-proxy</artifactId>
        <version>2.1.5</version>
        <type>pom</type>
    </dependency>
    <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>4.7.1</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-html -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-html</artifactId>
        <version>0.2.7</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-jvm-deps -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-jvm-deps</artifactId>
        <version>1.0.6</version>
        <scope>provided</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/net.masterthought/cucumber-reporting -->
    <dependency>
        <groupId>net.masterthought</groupId>
        <artifactId>cucumber-reporting</artifactId>
        <version>4.9.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest-core -->
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-core</artifactId>
        <version>2.1</version>
        <scope>test</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>4.7.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-core -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-core</artifactId>
        <version>4.7.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.codehaus.mojo/cobertura-maven-plugin -->
    <dependency>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
        <version>2.7</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/io.cucumber/gherkin -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>gherkin</artifactId>
        <version>5.1.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/io.cucumber/gherkin3 -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>gherkin3</artifactId>
        <version>3.1.2</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.141.5</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/junit/junit -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>4.1.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>4.1.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.aventstack/extentreports -->
    <dependency>
        <groupId>com.aventstack</groupId>
        <artifactId>extentreports</artifactId>
        <version>4.0.9</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.testng/testng -->
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.14.3</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-testng -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-testng</artifactId>
        <version>2.0.0</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.8.6</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.26</version>
    </dependency>

    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>23.0</version>
    </dependency>

</dependencies>


I get below error: "C:/Work/UIAutomation/HTest/src/test/java/com/pages/SalesForce/DevicesForEachMeasurement.java: Some input files use unchecked or unsafe operations." "C:/Work/UIAutomation/HTest/src/test/java/com/pages/SalesForce/DevicesForEachMeasurement.java: Recompile with -Xlint:unchecked for details."

I executed below command for more details: "javac C:/Work/UIAutomation/HTest/src/test/java/com/pages/SalesForce/DevicesForEachMeasurement.java -Xlint:unchecked" and found that its not recoginizing any of my imports, below are details: "error: package com.google.gson does not exist" "package org.openqa.selenium does not exist" "error: cannot find symbol" class files also not getting recogized

Kindly help me in resolving this issue.

aaschmid commented 4 years ago

@Harikahema1:

I will have a deeper look as soon as I have more time...

Harikahema1 commented 4 years ago

@aaschmid Thank you for the response.

Do you also have a unit test file which I can run to try reproducing your error? -> no Do you use the same command line arguments when running the tests from your IDE? -> No i haven't used command line arguments when running test from intellij IDE, I use to run from TestRunner.class

below is the screenshot of structure of my project:

image

Harikahema1 commented 4 years ago

@aaschmid
I tried to run scripts through the same command line arguments from intellij IDE and i got the same error: " error: package com.google.gson does not exist" "error: package com.core does not exist" .....etc etc

aaschmid commented 4 years ago

So, would you aggree that it is somehow related to -Dcucumber.options="--tags @automated" command line arg, right?

Harikahema1 commented 4 years ago

I am not sure. I even tried using simple maven command for running scripts "mvn test" followed by "mvn clean" , still i get the same error.

i just want to run all the tagged(@automated) test scenarios through maven command line.

aaschmid commented 4 years ago

Start looking deeper into the provided data, I haven't found a junit-dataprovider dependency in your pom.xml.

BTW: Do you know JGiven which provides you a more a developer-friendly and pragmatic BDD tool for Java using plain Java with a fluent, domain-specific API. This would support junit-dataprovider out-of-the-box :-)

aaschmid commented 4 years ago

Some more hints which I found trying to create a simple reproducer:

aaschmid commented 4 years ago

Closed due to no further response. Please don't hesitate to reopen