1

I have a cucumber framework which is catering to API as well as UI feature files. So, I have 2 feature files one for API and the other for UI. Similarly, I have created 2 classes in my step definition folder one for UI and other for API. So the structure is something like below :

featureFiles

--feature file for API

--feature file for UI

stepDefinition

--stepDefAPI

--stepDefUI

TestRunner

--UITestRunner

--APITestRunner

gluecode for both are stepDefinition, however, if I run APITestRunner, it says Test Class not found in specific project. However, when i segregate my stepDefAPI in some other package and only leave stepDefUI in that package then it works correctly. I can infer that it is happening because both the classes are in same package, doesn't cucumber support this kind of structure ?

brij
  • 331
  • 1
  • 5
  • 17

1 Answers1

0

Cucumber will load the glue in the directory and subdirectories. If you want to use different step definitions for UI and for API, create two subdirectories in your stepDefinition package and provide each relevant directory to the relevant runner. I.e. the UI directory to the UI runner and the API directory to the API runner.

Marit
  • 2,399
  • 18
  • 27
  • what if I want to run my API and UI test cases together ? If I make separate directories then i cannot run both the test cases with a single testRunner file ? – brij Oct 12 '18 at 04:56
  • Can you provide the code for `stepDefAPI` and `stepDefUI`? I'm not sure what you're trying to do. – Marit Oct 12 '18 at 13:55
  • Would not be able to share the code owing to some security concerns of my company, apologies for it. – brij Oct 18 '18 at 04:05
  • However, we can have multiple step definition classes inside a step def package right ? – brij Oct 18 '18 at 04:06
  • Yes, you can. To run both API and UI test cases, you could create 2 separate runners and run both of them. From you IDE (I use IntelliJ) you should be able to do so by selecting both of them and selecting "run". On our build server we use Surefire to run multiple runners. – Marit Oct 19 '18 at 13:01