apache-camelcitrus-frameworkapache-camel-k

Yaks on Camel K does not find the integration .groovy file


I'm using camel k on a project and I've tried use yaks framework for testing integrations routes.

When I execute the command to begin the test which is written in a .feature file the .groovy file is not found. Does anyone have a clue about it?

helloworld.feature

Feature: Hello
    Scenario: Print hello message
        Given load Camel K integration myIntegration.groovy
        Given Camel K integration myIntegration is running
        Then Camel K integration myIntegration should print Hello world from Camel K!

integration myIntegration.groovy

from('timer:tick?period=10000')
  .setBody()
  .constant('Hello world from Camel K!')
  .to('log:info')

CLI command

yaks test helloworld.feature -n dev-camelk 

Logs:

[test-helloworld-c91h513v71u96jkmfqbg-g56mw test-1] 1 Scenarios (1 failed)
[test-helloworld-c91h513v71u96jkmfqbg-g56mw test-1] 3 Steps (1 failed, 2 skipped)
[test-helloworld-c91h513v71u96jkmfqbg-g56mw test-1] 0m1.987s
**[test-helloworld-c91h513v71u96jkmfqbg-g56mw test-1] com.consol.citrus.exceptions.CitrusRuntimeException: Failed to load Camel K integration from resource mob2.groovy**
[test-helloworld-c91h513v71u96jkmfqbg-g56mw test-1]     at org.citrusframework.yaks.camelk.CamelKSteps.loadIntegrationFromFile(CamelKSteps.java:141)
[test-helloworld-c91h513v71u96jkmfqbg-g56mw test-1]     at ✽.load Camel K integration mob2.groovy(classpath:org/citrusframework/yaks/helloworld.feature:3)
[test-helloworld-c91h513v71u96jkmfqbg-g56mw test-1] Caused by: **java.io.FileNotFoundException: class path resource [myIntegration.groovy] cannot be opened because it does not exist**
[test-helloworld-c91h513v71u96jkmfqbg-g56mw test-1]     at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:199)

Thank you!


Solution

  • There are a couple of problems in the way you call it. The integration name is generally kebab case for Camel K integration, so, your feature must be:

    Feature: Hello
    Scenario: Print hello message
        Given load Camel K integration myIntegration.groovy
        Given Camel K integration my-integration is running
        Then Camel K integration my-integration should print Hello world from Camel K!
    

    Then, you must provide the integration file resource via --resource option, such as:

    yaks run helloworld.feature --resource myIntegration.groovy
    

    Hope it helps!