0

Just started with Karate API test sample project and encountered with this issue.

My pom.xml

<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>Karate</groupId>
    <artifactId>com.Karate</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
        <maven.compiler.version>3.6.0</maven.compiler.version>
        <karate.version>0.9.4</karate.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.intuit.karate</groupId>
            <artifactId>karate-apache</artifactId>
            <version>${karate.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.intuit.karate/karate-testng -->
        <dependency>
            <groupId>com.intuit.karate</groupId>
            <artifactId>karate-testng</artifactId>
            <version>0.8.0.1</version>
        </dependency>


    </dependencies>

    <build>
        <testResources>
            <testResource>
                <directory>src/test/java</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.version}</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <compilerArgument>-Werror</compilerArgument>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
                <configuration>
                    <suitXmlFiles>
                        <suiteXmlFile>textng.xml</suiteXmlFile>
                    </suitXmlFiles>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

testng.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
 <suite >
  <test >
    <classes>
      <class name="examples.users.UsersRunner"/>
    </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->

src/test/java/examples/users/UserRunner.java

package examples.users;
import com.intuit.karate.KarateOptions;
import com.intuit.karate.testng.KarateRunner;
@KarateOptions(features = "src/test/java/examples.users")
class UsersRunner extends KarateRunner {}

Feature file:country.feature

@feature1
Feature: Validate country API for listed countries to return
    Backgroud: * url 'https://restcountries.eu'

    Sceanrio: get country names contains work united
    Given path 'rest/v2/name/united'
    When method GET
    Then status 200

While running with mvn clean test, below is error:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building com.Karate 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ com.Karate ---
[INFO] Deleting C:\Users\lalit\workspace\com.Karate\target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ com.Karate ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\lalit\workspace\com.Karate\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.0:compile (default-compile) @ com.Karate ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ com.Karate ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.0:testCompile (default-testCompile) @ com.Karate ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to C:\Users\lalit\workspace\com.Karate\target\test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ com.Karate ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running examples.ExamplesTest
[TestNGClassFinder] Warning: Can't link and determine methods of class examples.ExamplesTest
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.463 s - in examples.ExamplesTest
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.312 s
[INFO] Finished at: 2019-10-12T18:48:13-04:00
[INFO] Final Memory: 17M/169M
[INFO] ------------------------------------------------------------------------
  • 1
    are you running the mvn command from the root of the project? – masood ghz Oct 14 at 9:45
  • If this is the full class code class UsersRunner extends KarateRunner {} then you just do not have anything to run here – wec Oct 15 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.