1

Тема: Хелп з cucumber (Junit)

Маю помилку
TODO: implement me
cucumber.api.PendingException: TODO: implement me
    at cucumber.runtime.junit.JUnitReporter.addFailure(JUnitReporter.java:150)
    at cucumber.runtime.junit.JUnitReporter.addFailureOrIgnoreStep(JUnitReporter.java:138)
    at cucumber.runtime.junit.JUnitReporter.result(JUnitReporter.java:98)
    at cucumber.runtime.Runtime.runStep(Runtime.java:282)
    at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
    at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
    at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
    at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:102)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:63)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:18)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:70)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:95)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:38)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at cucumber.api.junit.Cucumber.run(Cucumber.java:100)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:114)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:57)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:66)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
    at com.sun.proxy.$Proxy1.processTestClass(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:108)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:146)
    at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:128)
    at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.lang.Thread.run(Thread.java:750)

Код Junit

@Then("^Add bad Chocolate recipte Name is (\\D+) Need Chocolate is (\\d+) Need Coffee is (\\d+) Need Milk is (\\d+) Need Sugar is (\\d+) Price is (\\d+)$")
    public void Add_bad_recipte(String name,String Chocolate,String Coffee,String Milk,String Sugar,String Price) throws RecipeException {
        try {
            Recipe TestreRecipe = new Recipe() ;
            TestreRecipe.setName(name);
            TestreRecipe.setAmtChocolate(Chocolate);
            TestreRecipe.setAmtCoffee(Coffee);
            TestreRecipe.setAmtMilk(Milk);
            TestreRecipe.setAmtSugar(Sugar);
            TestreRecipe.setPrice(Price);
            Command cmd = new DescribeRecipe(TestreRecipe);
            coffeeMakerMain.mode = CoffeeMakerUI.Mode.ADD_RECIPE;
            coffeeMakerMain.UI_Input(cmd);
        }catch (RecipeException e) {
            Command cmd = new DescribeRecipe(null);
            coffeeMakerMain.mode = CoffeeMakerUI.Mode.ADD_RECIPE;
            coffeeMakerMain.UI_Input(cmd);
            assertEquals("Units of chocolate must be a positive integer",e.getMessage());
        }

    }

Код cucumber

Scenario: Add 1 bad Recipes
    Given an empty recipe book
    Then Add bad Chocolate recipte Name is Coffe Need Chocolate is -1 Need Coffee is 1 Need Milk is 1 Need Sugar is 1 Price is 1
    And Mode is WAITING
    And Status is RECIPE_NOT_ADDED

Код setAmtChocolate(Chocolate)

public void setAmtChocolate(String chocolate) throws RecipeException {
    int amtChocolate = 0;
    try {
        amtChocolate = Integer.parseInt(chocolate);
    } catch (NumberFormatException e) {
        throw new RecipeException("Units of chocolate must be a positive integer");
    }
    if (amtChocolate >= 0) {
        this.amtChocolate = amtChocolate;
    } else {
        throw new RecipeException("Units of chocolate must be a positive integer");
    }
}

Допоможіть. Хочу написати сценарій де вписую не коректні дані і ловлю помилку . Другий день ламаю голову, що я роблю не правильно ?

2

Re: Хелп з cucumber (Junit)

Помилка була в регулярному виразі який приймав тільки додатнє число

Подякували: leofun01, koala, bebyk3