Search code examples
testingpom.xmlkarate

I want to remove folder src/test/java from my Karate project but on removing no test cases are getting executed


I am a beginner in Karate so I have been making a Karate Project and I want to remove src/test/java and put all files and folders in a single folder, let's say 'test-folder'. The test cases were running fine before but on replacing src/test/java with 'test-folder', no test files get executed. It shows ' No sources to compile' and 'Build Success'.

I changed the test directory name in pom.xml also but still the problem persists.

pom.xml :-

` <groupId>com.mycompany</groupId>
<artifactId>KarateProject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>11</java.version>
    <maven.compiler.version>3.6.0</maven.compiler.version>
    <karate.version>1.3.1</karate.version>
    <gatling.plugin.version>4.2.9</gatling.plugin.version>
</properties>    

<dependencies>          
    <dependency>
        <groupId>com.intuit.karate</groupId>
        <artifactId>karate-junit5</artifactId>
        <version>${karate.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.github.javafaker</groupId>
        <artifactId>javafaker</artifactId>
        <version>1.0.2</version>
    </dependency>
    <dependency>
        <groupId>net.masterthought</groupId>
        <artifactId>cucumber-reporting</artifactId>
        <version>5.3.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.intuit.karate</groupId>
        <artifactId>karate-gatling</artifactId>
        <version>${karate.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>42.6.0</version>
</dependency>       
<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>5.2.6.RELEASE</version>
        <scope>test</scope> 
    </dependency>
</dependencies>

<build>
    <testResources>
        <testResource>
            <directory>test-folder</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>
                <systemProperties>
                    <karate.options>--tags ~@ignore</karate.options>
                </systemProperties>            
            </configuration>
        </plugin>
        <plugin>
            <groupId>io.gatling</groupId>
            <artifactId>gatling-maven-plugin</artifactId>
            <version>${gatling.plugin.version}</version>
            <configuration>
                <simulationsFolder>test-folder/conduit/performance</simulationsFolder>
                <configFolder>test-folder/conduit/performance/data</configFolder>
            </configuration>             
        </plugin>
        <plugin>
            <groupId>net.alchim31.maven</groupId>
            <artifactId>scala-maven-plugin</artifactId>
            <version>4.5.6</version>
            <executions>
                <execution>
                    <goals>
                        <goal>testCompile</goal>
                    </goals>
                    <configuration>
                        <args>
                            <arg>-Jbackend:GenBCode</arg>
                            <arg>-Jdelambdafy:method</arg>
                            <arg>-target:jvm-1.8</arg>
                            <arg>-deprecation</arg>
                            <arg>-feature</arg>
                            <arg>-unchecked</arg>
                            <arg>-language:implicitConversions</arg>
                            <arg>-language:postfixOps</arg>
                        </args>
                    </configuration>
                </execution>
            </executions>
        </plugin>            
    </plugins>        
</build>       

`


Solution

  • What you are doing is not supported. As a beginner, I suggest you stick to standard patterns, refer to the examples: https://github.com/karatelabs/karate-examples/blob/main/README.md