0

I've set up a test file in src/main/java with my cucumber annotations containing class A, as well as a test file extending class A in src/test/java with the following annotation on class B:

        @ContextConfiguration(locations = {"classpath:META-INF/application-config.xml", "classpath:META-INF/overrule.xml" })

This is working fine when I do a maven clean install. What I would like to achieve though is being able to run a feature file through the cucumber setup of class A and see its output. So far I've managed to find a method which should allow me to run the cucumber test, but I can't seem to figure out what its arguments should be. Could anyone provide me with an example of how to implement the function cucumber.api.cli.Main.run()?

        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                final String[] arguments = {"foo", "bar" };
                cucumber.api.cli.Main.run(arguments, ClassLoader.getSystemClassLoader());
            } catch (final Throwable e) {
                e.printStackTrace();
            }
        }

1 Answers1

1

I would invoke the command line version using cucumber.api.cli.Main.main(args);

where args is a String array with the parameters set. I would not use the run command you refer to.

The documentation describes all available options.

Another source may be the getting started project supplied by the Cucumber team: https://github.com/cucumber/cucumber-java-skeleton

It may be of specific interest to look into the Ant build script https://github.com/cucumber/cucumber-java-skeleton/blob/master/build.xml to see what arguments they supply to Cucumber.

Thomas Sundberg
  • 4,098
  • 3
  • 18
  • 25
  • The main command runs the run command followed by System.exit(); Since I need to keep the application running afterwards, calling main isn't a valid option. I managed to get the arguments correct. What I'm dealing with though is getting the ClassLoader to work correctly with Spring (which I just realized I forgot to mention) – Joey van Gangelen Jan 04 '17 at 12:14