Cucumber: Unable to find step definition -
Cucumber: Unable to find step definition -
i have next feature file: macrovalidation.feature
@macrofilter feature: separating out errors , warnings scenario: no errors or warnings when separating out error list given have 0 macros when filter out errors , warnings macros need have 0 errors , need have 0 warnings
my definition files.
class="lang-java prettyprint-override">package com.test.definition; import cucumber.api.java.after; import cucumber.api.java.before; import cucumber.api.java.en.given; import cucumber.api.java.en.then; import cucumber.api.java.en.when; import cucumber.runtime.java.stepdefannotation; import java.util.arraylist; import java.util.arrays; import java.util.list; import static org.junit.assert.assertequals; import static org.junit.assert.asserttrue; import static org.powermock.api.mockito.powermockito.doreturn; import static org.powermock.api.mockito.powermockito.mock; import static org.powermock.api.mockito.powermockito.spy; @stepdefannotation public class macrovalidationstepdefinitions { private final macroservice macroservice = spy(new macroservice()); private final llrbuslist buslist = mock(llrbuslist.class); private final list<string> errorlist = new arraylist<string>(); private final list<string> warninglist = new arraylist<string>(); @before({"@macrofilter"}) public void setup() { errorlist.addall(arrays.aslist("error 1, error2, error 3")); warninglist.addall(arrays.aslist("warning 1, warning 2, warning 3")); } @after({"@macrofilter"}) public void teardown() { errorlist.clear(); warninglist.clear(); } @given("^i have (\\d+) macros$") public void i_have_macros(int input) { doreturn(input).when(buslist).size(); } @when("^i filtered out errors , warnings macros$") public void i_filtered_out_errors_and_warnings_for_macros() { macroservice.separateerrorsandwarning(buslist, errorlist, warninglist); } @then("^i need have (\\d+) errors$") public void i_need_to_have_errors(int numoferror) { if (numoferror == 0) { asserttrue(errorlist.isempty()); } else { assertequals(errorlist.size(), numoferror); } } @then("^i need have (\\d+) warnings$") public void i_need_to_have_warnings(int numofwarnings) { if (numofwarnings == 0) { asserttrue(warninglist.isempty()); } else { assertequals(warninglist.size(), numofwarnings); } } }
my unit test class.
class="lang-java prettyprint-override">@cucumberoptions(features = {"classpath:testfiles/macrovalidation.feature"}, glue = {"com.macro.definition"}, dryrun = false, monochrome = true, tags = "@macrofilter" ) @runwith(cucumber.class) public class pagemacrovalidationtest { }
when execute test, file definition not implemented warnings in log.
example log:
class="lang-java prettyprint-override">you can implement missing steps snippets below: @given("^i have (\\d+) macros$") public void i_have_macros(int arg1) throws throwable { // write code here turns phrase above concrete actions throw new pendingexception(); } @when("^i filter out errors , warnings macros$") public void i_filter_out_errors_and_warnings_for_macros() throws throwable { // write code here turns phrase above concrete actions throw new pendingexception(); } @then("^i need have (\\d+) errors$") public void i_need_to_have_errors(int arg1) throws throwable { // write code here turns phrase above concrete actions throw new pendingexception(); } @then("^i need have (\\d+) warnings$") public void i_need_to_have_warnings(int arg1) throws throwable { // write code here turns phrase above concrete actions throw new pendingexception(); }
i don't think file name should matter right?
it looks cucumber isn't finding step defintion class. in unit test class say:
glue = {"com.macro.definition"}
however step definition classes in com.test.definition
try changing line to:
glue = {"com.test.definition"}
cucumber-jvm cucumber-junit
Comments
Post a Comment