I made a Spring Boot 2
application with one endpoint to execute Cucumber test
for 5.7.0 version
@PostMapping("/integration")
public Object runCucumber(@RequestBody List<String> request) {
try {
String pathDirectory = "src/main/resources/" + request.get(0);
String response = String.valueOf(Main.run(new String[]{"--glue", //Cucumber type (--glue)
"pmc/aop/integration", // the package which contains the glue classes
pathDirectory} //Step package
, Thread.currentThread().getContextClassLoader()));
return ResponseEntity.ok(request);
} catch (HttpClientErrorException ex) {
log.error(ex.getLocalizedMessage());
return ResponseEntity.status(ex.getStatusCode()).body(ex.getStatusText());
} catch (IllegalArgumentException ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(ex.getLocalizedMessage());
}
}
The request used
[
"features/local/notify.feature"
]
As you can see I'd like to execute the notify.feature
inside of local
folder, inside of features
folder, inside of resources
folder
this is the configuration
@SpringBootTest
@AutoConfigureMockMvc
@CucumberContextConfiguration
@CucumberOptions(features="src/main/resources")
public class CucumberConfiguration {
}
Everything is going good, locally but on my server I got
path must exist: /app/src/main/resources/features/local/heal.feature
What's wrong?
When your application is deployed the src/main/resources/
directory does not exist. You can verify this by inspecting the contents of the jar or war file you've created.
Instead, try locating the feature on the class path. E.g. classpath:com/example/app/my.feature
.