Reputation: 94
I have my junit tests for my spring api project in src/test/java
. For testing the controllers, I have created a package com.example.controller
, inside which I have my karate feature file sample.feature:
Feature: sample
Scenario: Test Create
Given path '/test'
Given url 'https://localhost:8443'
When method GET
Then status 200
Below is my Test class:
package com.example.controller;
import com.intuit.karate.junit5.Karate;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
public class ControllerTest {
@Karate.Test
Karate testSample() {
return Karate.run("sample").relativeTo(getClass());
}
}
For the mentioned setup, I am getting the following error:
org.opentest4j.AssertionFailedError: http call failed after 105 milliseconds for url: https://localhost:8443/test
For execution, I am using mvn clean test -Dtest=ControllerTest
I have karate-core:1.0.1
and karate-junit5:1.0.1
in my pom.xml, along with junit exclusions to the karate package. I want to run the karate feature file while my application is running, similar to how other junits are executed.
Anything which I might be missing / incorrectly configured in such scenario?
Reference link from Karate Project.
Upvotes: 1
Views: 2234
Reputation: 58128
I don't think @Karate.Test
is compatible with @SpringBootTest
so you may need to figure this out on your own.
Here's a tip - the Karate JUnit support is just a convenience which is not mandatory to use. You may be able to create reasonable test suites that play well with @SpringBootTest
using the Karate "core" Runner
class.
For a detailed explanation, see: https://stackoverflow.com/a/65578167/143475
Upvotes: 1