sebaslogen / CleanGUITestArchitecture

Sample project of Android GUI test automation using Espresso, Cucumber and the Page Object Pattern
MIT License
137 stars 31 forks source link

Getting "cucumber.runtime.CucumberException" error on running the "StepDefinitions" #23

Closed vsgopinath closed 6 years ago

vsgopinath commented 6 years ago

Hi Sebas, As discussed,I am raising this issue for the below error message on running the "StepDefinitions":

Test running failed: Instrumentation run failed due to 'cucumber.runtime.CucumberException' Empty test suite.

I have placed my "CucumberTestCase" in the "com.myapp.account.test"(androidTest) package and the cucumber pages,runner and steps in the "com.myapp.account.cucumber.pages/runner/steps"(androidTest) packages respectively.

And the feature folder is in "app\src\androidTest\assets" package.

Let me know if you need further information on my project structure

CucumberTestCase.txt

sebaslogen commented 6 years ago

In the .feature file inside your features folder, do you have a line starting with "Feature:" and another one starting with "Scenario:" and above this line the tag @login-scenarios like in the sample? https://github.com/sebaslogen/CleanGUITestArchitecture/blob/master/app/src/androidTest/assets/features/login.feature

vsgopinath commented 6 years ago

yeah.I have the keywords "Features" & "Scenario" in my login.feature like this:

Feature: Login in the application

@login-scenarios Scenario: User can login with valid user name and password Given I see the login page When I login with user name "admin" and password "admin" Then I see the welcome page

In regards to the error message, I ran in CMD and got this detailed error message:

INSTRUMENTATION_RESULT: shortMsg=cucumber.runtime.CucumberException INSTRUMENTATION_RESULT: longMsg=cucumber.runtime.CucumberException: No CucumberOptions annotation INSTRUMENTATION_CODE: 0

sebaslogen commented 6 years ago

I don't know what is the problem with your project configuration. My suggestion is that you try to run the code in this sample project as it is, once you have that working start copy&pasting code from one project to the other and see if you can make it run.

vsgopinath commented 6 years ago

@sebaslogen It is working in the sample project.The only difference I found is that my project is having three flavors say alpha,beta & gamma.Is that "CucumberTestcase.java" need to be copied to each of those flavors folders? If so what will be the package name standards for the flavors?

          The problem might be "CucumberTestCase" is not found while running tests for the flavors.

Any suggestions ?

sebaslogen commented 6 years ago

Did you follow the advice in the sample code about flavors? https://github.com/sebaslogen/CleanGUITestArchitecture/blob/master/app/src/androidTest/java/com/neoranga55/cleanguitestarchitecture/test/CucumberTestCase.java#L9

vsgopinath commented 6 years ago

Yes @sebaslogen .I did follow as mentioned in the Cucumber Test Case file. I am able to successfully configure for an android app which is not having flavors but I could not able to configure for the enterprise app which is having flavors.I just copy pasted the "androidTest" folder files of the working App to "androidTestFalvor1" folder of enterprise App.But,I am still getting the same error.

"Test running failed: Instrumentation run failed due to 'cucumber.runtime.CucumberException' Empty Test Suite "

Let me know your thoughts on this.

And if possible,can you share a sample project with flavors having cucumber tests and runners.I could not able to figure out where its going wrong as the project without flavors is working very smooth with your framework.

sebaslogen commented 6 years ago

Just share the structure of your test folder with flavors and which file is where. Do you share test cases and test step definitions between flavors? What is the difference between your flavors folders under /flavorX/androidTest ?

vsgopinath commented 6 years ago

@sebaslogen I have a created a sample android project with flavors where also I am getting the same error. Please find the path for the repo below:

https://github.com/vsgopinath/AppWithFlavors.git

Let me know if you need further information

sebaslogen commented 6 years ago

I see the package name is incorrect in this file: https://github.com/vsgopinath/AppWithFlavors/blob/afcbfc87365182a3fec5baeb09ba2686c7ccfb8d/app/src/androidTestFlavor1/java/com/example/gviswa200/myapplication/flavor1/test/CucumberTestCase.java#L1

It should be com.example.gviswa200.myapplication.flavor1.test

vsgopinath commented 6 years ago

I have corrected the package name now and added debug folder for flavor1 and added the AndroidManifest.xml in that folder. Still getting the "Empty test suite error".

sebaslogen commented 6 years ago

I tried for a while but unfortunately, I can't figure out why it doesn't work. All I can tell you is that tests on flavors worked in a previous business project I used to work

vsgopinath commented 6 years ago

Okay @sebaslogen. Thank you so much for your valuable time and effort.Can we look for help in stackoverflow?

Do you want to close this issue?

sebaslogen commented 6 years ago

It's ok to leave the issue open because it's not fixed and other people might find this information useful.

vsgopinath commented 6 years ago

@sebaslogen Let me post the sample project in stack overflow and we will look for resolution.Please let me know if you can able to fix this in near future

vsgopinath commented 6 years ago

@sebaslogen I tried to configure "CleanGuiTestArchitecture" app with flavors and with AndroidTests.I am getting the same error as well.If its possible,can you try this project (CleanGuiTestArchitecture) with a flavor and configure the Cucumber Test for that flavor?

sebaslogen commented 6 years ago

@vsgopinath unfortunately I don't have time to help further.

vsgopinath commented 6 years ago

@sebaslogen Thanks so much for your help.I am able to resolve the issue as its due to dependency issues.As you instructed in CucumberTestCase.java file,its working fine with those changes.

Closing this issue.

bohsen commented 6 years ago

@vsgopinath Accidently stumbled upon this and I know the issue is closed, but have you checked that your testInstrumentationTestRunner in your build.gradle file is correctly set? This type of mistake is most often associated with such this type of error.

@sebaslogen Great article by the way

vsgopinath commented 6 years ago

@bohsen My application has flavors which made me difficult to configure since I am very new to Android & Espresso testing.Finally I figured out the correct folders for placing the Cucumber Test Case and the runner class and I changed few of the dependency to the latest which helped me resolve this issue. Yeah as you pointed out,I do face issues due to Instrumentation class and I am able to resolve that also.

As @sebaslogen mentioned in the project,I made changes as per his comments and its really working damn good now 👍

And @sebaslogen I am unable to find the screenshots embedded in the html report.Any suggestions on how to find the screenshots.