I have a GraphQL service that i'm using Karate to test. I have a feature for mutations and a couple features for queries. I'm doing a Spring Boot integration test, like so
@SpringBootTest(classes=ApplicationTest.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class RunUnitCukeTest implements InitializingBean {
@LocalServerPort
int port;
@Karate.Test
Karate runTest() {
return new Karate()//
.feature("classpath:features/TestMutationsAndDatabaseSetup.feature")
.feature("classpath:features/Queries.feature");
}
My thinking is, rather than staging a bunch of data into my H2 database in code, I could instead just test my mutations first (thus staging some data), and then test my queries/the calculations those queries need to do.
When my mutations feature runs, everything works fine. But my Queries feature isn't seeing any data. Which makes me wonder if they're running in the opposite order as I want, and if there's any way to get them to run sequentially.
Well, perhaps you should read this first: https://stackoverflow.com/a/46080568/143475
Maybe what you should do is use karate.callSingle()
in the karate-config.js
to do the mutations, and then kick off the rest of the tests.
Yes, Karate is designed to run tests in parallel and force you to NOT have dependencies across your Scenario
-s, let alone Feature
-s.
Note that the @Karate.Test
annotation is NOT the recommended way to run test-suites in CI: https://stackoverflow.com/a/65578167/143475 - and I don't think it honors the order in which you call feature()
.
If the mutation flows are pure "set up", just call it in your JUnit code before running your "main" suite: https://stackoverflow.com/a/60944060/143475