Rahul
Rahul

Reputation: 239

Converting Cucumber Java Project to Maven Project and Running in Jenkins

I have converted my java project (which is built using cucumber framework) to Maven Project. Am not able to use Sure Fire Plugin , since my folder structure is not as this format "src/test/java"

My folder structure is testng xml consisting information of cucumber runner file , now my aim is to trigger this testng xml in jenkins.

am aware of executing testng xml from command prompt , but to do that , we need to have lib folder in place. Since am using Maven , i dont have local lib folder. Can someone please suggest , what to do in this case ? (don't want to change the folder structure)

Thanks in advance

Upvotes: 0

Views: 2256

Answers (1)

Krishnan Mahadevan
Krishnan Mahadevan

Reputation: 14736

You first bring in the required dependencies for your CLASSPATH, by adding <dependency> entries into your pom file.

In short, you would need to add atleast the below ones

<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-testng -->
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-testng</artifactId>
    <version>1.2.5</version>
    <exclusions>
        <!-- ignoring older version of testng -->
        <exclusion>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.11</version>
    <!-- Remove the scope tag, if you have some TestNG listener code residing in src/main/java -->
    <scope>test</scope>
</dependency>

Now add the below entries to tell Maven where your test classes reside and where your test resources reside.

<build>
    <!-- test sources represents the folder where in your classes that contain @Test methods reside-->
    <testSourceDirectory></testSourceDirectory>
    <!-- test resources represents the folder which contains your .feature files, your .suite xml etc-->
    <testResources></testResources>
</build>

For more details on how to tweak surefire plugin's behavior refer here.

Upvotes: 2

Related Questions