citrusframework / citrus

Framework for automated integration tests with focus on messaging integration
https://citrusframework.org
Apache License 2.0
459 stars 136 forks source link

Simple Cucumber HTTP fails #674

Open nicolaferraro opened 5 years ago

nicolaferraro commented 5 years ago

Citrus Version 2.8.0

Expected behavior Test passes.

Actual behavior It fails.

Test case sample

Please, share the test case (as small as possible) which shows the issue

I'm new to Citrus and Cucumber, but I'm trying a simple HTTP test that fails:

Feature: Integration Works

  Scenario: Get a result from API
    Given URL: https://www.wikipedia.org
    When send GET /
    Then receive status 200 OK

All three steps seem to work, but I receive an exception at the end.

Failed scenarios:
./my.feature:3 # Get a result from API

1 Scenarios (1 failed)
3 Steps (3 passed)
0m26.283s

com.consol.citrus.exceptions.TestCaseFailedException: Neither endpoint nor endpoint uri is set properly!
    at com.consol.citrus.TestCase.executeAction(TestCase.java:227)
    at com.consol.citrus.TestCase.doExecute(TestCase.java:152)
    at com.consol.citrus.actions.AbstractTestAction.execute(AbstractTestAction.java:42)
    at com.consol.citrus.Citrus.run(Citrus.java:403)
    at com.consol.citrus.Citrus.run(Citrus.java:394)
    at com.consol.citrus.cucumber.CitrusLifecycleHooks.after(CitrusLifecycleHooks.java:61)
    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 cucumber.runtime.Utils$1.call(Utils.java:26)
    at cucumber.runtime.Timeout.timeout(Timeout.java:16)
    at cucumber.runtime.Utils.invoke(Utils.java:20)
    at cucumber.runtime.java.JavaHookDefinition.execute(JavaHookDefinition.java:60)
    at cucumber.runtime.HookDefinitionMatch.runStep(HookDefinitionMatch.java:14)
    at cucumber.runner.TestStep.executeStep(TestStep.java:55)
    at cucumber.runner.TestStep.run(TestStep.java:42)
    at cucumber.runner.TestCase.run(TestCase.java:53)
    at cucumber.runner.Runner.runPickle(Runner.java:44)
    at cucumber.runtime.Runtime.runFeature(Runtime.java:120)
    at cucumber.runtime.Runtime.run(Runtime.java:106)
    at org.apache.camel.k.testing.TestRunner.main(TestRunner.java:52)
Caused by: com.consol.citrus.exceptions.CitrusRuntimeException: Neither endpoint nor endpoint uri is set properly!
    at com.consol.citrus.actions.SendMessageAction.getOrCreateEndpoint(SendMessageAction.java:176)
    at com.consol.citrus.actions.SendMessageAction.isDisabled(SendMessageAction.java:137)
    at com.consol.citrus.dsl.actions.DelegatingTestAction.isDisabled(DelegatingTestAction.java:60)
    at com.consol.citrus.TestCase.executeAction(TestCase.java:216)
    ... 21 more

cc: @christophd

christophd commented 5 years ago

Here is what I did for DevoxxBE as demo: https://github.com/christophd/citrus-demo-devoxx-be

In particular review these bits: voting-rest-api.feature VotingRestFeatureIT.java cucumber.properties

christophd commented 5 years ago

You have to set a http client in the Spring bean application context to make this work.

I would consider this as a bug because the client is only used to get passed the failing endpoint check and is not required to run the scenario. Maybe we should automatically add the client on the fly when no explicit default client is set in application context.

mbit2023 commented 9 months ago

I encountered the same problem and fixed it like this:

Define a httpClient Bean, e.g.
<citrus-http:client id="httpClientENO005" request-url="http://localhost:8090/services/enova/invoicesKSeF/read"/>

Then in your feature file you need to tell which httpClient you're using:

Feature: Read KSeF sales invoices
  Background: 
     Given http-client "httpClientENO005"

   Scenario: Get Invoices OK
     When send GET /sale
     Then receive status 200 OK