2

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"
]

enter image description here

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?

TuGordoBello
  • 4,350
  • 9
  • 52
  • 78
  • Aren't those directories supposed to be named like `features.local` instead of `f.local` etc? – Minar Mahmud Jun 03 '20 at 16:39
  • @MinarMahmud I know the extension file is ``.feature``. I guess the directory name doesn't matter – TuGordoBello Jun 03 '20 at 18:32
  • `path must exist: /app/src/main/resources/features/local/heal.feature`. it is searching in a path where directory name is `feature` but not `f`. You might consider changing that and see what happens – Minar Mahmud Jun 03 '20 at 18:34
  • @MinarMahmud sorry for misunderstand. My IDE has flatten packages. I change the image – TuGordoBello Jun 03 '20 at 19:00

1 Answers1

1

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.

TuGordoBello
  • 4,350
  • 9
  • 52
  • 78
M.P. Korstanje
  • 10,426
  • 3
  • 36
  • 58