Trying to read files in /resources in karate and getting: could not find or read file

91 views Asked by At

Read this: https://github.com/karatelabs/karate#reading-files

It says how to set pom.xml for restricting classpath to not read /resources. Can i know what should be the pom.xml for classpath to read from src/test/java and src/test/resources

EDIT1:

Below is my pom.xml after removal of testResources. Can you please check if its as expected.

<profile>
        <id>karate</id>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven-surefire-plugin.version}</version>
                    <configuration>
                        <includes>
                            <include>karate/DemandForecastIntegrationTest.java</include>
                        </includes>
                        <properties>
                            <property>
                                <name>listener</name>
                                <value>org.sonar.java.jacoco.JUnitListener</value>
                            </property>
                        </properties>
                        <!-- March 2021 - during transition period, enable legacy mode for
                            Spring Boot 2.4 See https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-Config-Data-Migration-Guide#legacy-mode
                            and https://wiki.intuit.com/display/CTODevSP/Spring+Boot+2.4+Migration+Notes
                            . And we also need to set the system property spring.cloud.bootstrap.enabled
                            (or equivalent environment variable) to have Spring Boot 2.4 (Spring Cloud
                            2020) process bootstrap files! See above and https://docs.spring.io/spring-cloud-config/docs/3.0.0/reference/html/#config-data-import
                            and http://maven.apache.org/surefire/maven-surefire-plugin/faq.html#late-property-evaluation -->
                        <argLine>@{surefireArgLine} -Dspring.cloud.bootstrap.enabled=true
                            -Dspring.config.use-legacy-processing=true
                        </argLine>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${jacoco-maven-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>default-prepare-agent</id>
                            <configuration>
                                <destFile>${project.build.directory}/jacoco-it/jacoco-it.exec</destFile>
                            </configuration>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>default-report</id>
                            <phase>test</phase>
                            <configuration>
                                <dataFile>${project.build.directory}/jacoco-it/jacoco-it.exec</dataFile>
                                <outputDirectory>${project.build.directory}/jacoco-it/</outputDirectory>
                            </configuration>
                            <goals>
                                <goal>report</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>default-check</id>
                            <goals>
                                <goal>check</goal>
                            </goals>
                            <configuration>
                                <skip>true</skip>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
        <!-- End of Karate Testing -->
    </profile>
1

There are 1 answers

2
Peter Thomas On

It should be the defaults, where you don't have the <testResources> part in your pom.xml at all. In this case src/test/resources will be available in the classpath:.