Code Monkey home page Code Monkey logo

Comments (14)

willpowr avatar willpowr commented on June 2, 2024 3

Thanks for your time on this. I'm sure it will help 100s of people!
I ran the connectedAndroidTest as advised which completed successfully.
I edited the tags in the scenarios of the feature file to @login-scenario1, @login-scenario2, @login-scenario3
I added-Ptags="@login-scenario2" to Script parameters and re-ran the script.

SUCCESS! Only the 2nd scenario was executed.

The question remains however... Does Android Studio allow the more user friendly and visually appealing execution of feature files as quoted above?

from cleanguitestarchitecture.

sebaslogen avatar sebaslogen commented on June 2, 2024 2

Indeed, that's not possible because it's not how Cucumber recognizes tests.
Tests are recognized by tags rather than files or folders.

In addition, tags can be added before a "Feature: ..." line, not only before a "Scenario: ..." line. Example:

@login-feature
Feature: Login in the application

  @ScenarioId("FUNCTIONAL.AUTH.SCN.001") @UserStory("MyApp-135") @login-scenarios
  Scenario: User can login with valid user name and password
    Given I see the login page
    When I login with user name "Sebas" and password "passion"
    Then I see the welcome page
    And the title is "Welcome Sebas"

  @ScenarioId("FUNCTIONAL.AUTH.SCN.002") @UserStory("MyApp-135") @login-scenarios
  Scenario: User can login with valid second user name and password
    Given I see the login page
    When I login with user name "sebaslogen" and password "passion"
    Then I see the welcome page
    And the title is "Welcome sebaslogen"

from cleanguitestarchitecture.

ArunaBalasubramanian avatar ArunaBalasubramanian commented on June 2, 2024 1

Thanks @sebaslogen for the insight. I had to tweak a little on the project structure and finally it did work.

from cleanguitestarchitecture.

sebaslogen avatar sebaslogen commented on June 2, 2024

Hi,
Can you explain in more detail how are trying and failing to run the tests?

You can run tests from the IDE and from the command line but the execution is not filtered per file, but rather by tags (all tests are executed if no tag is given as filter). For more info see #15

from cleanguitestarchitecture.

willpowr avatar willpowr commented on June 2, 2024

I attempted the following steps...

  1. Select the Android view in the project pane.
  2. Expand the folder app/assets/features(androidTest)
  3. Right-click login.feature

image

from cleanguitestarchitecture.

willpowr avatar willpowr commented on June 2, 2024

The examples given pertain to running the test from the command line which works as expected in my environment. I guess my question is, how is it possible to run cucumber feature tests using Android Studio GUI using the Run window / toolbar run buttons? Can tags be used somewhere in the Run/Debug Configuration?

from cleanguitestarchitecture.

willpowr avatar willpowr commented on June 2, 2024

...The intellij documentation instructions seem to suggest right-clicking on feature files is doable.
https://www.jetbrains.com/help/idea/running-cucumber-tests.html

Running Cucumber Tests

The Cucumber feature files are run same way as the other executables, with certain run/debug configuration settings.

Prior to running a test, you have to set up run/debug configuration for a particular feature file or scenario, or for the whole bunch of features within a directory. Creating a run/debug configuration is described in the section Creating and Editing Run/Debug Configurations.

However, there is always the possibility to run Cucumber tests with the default settings, which is described below.

Results of tests execution are displayed in the Test Runner tab of the Run tool window.

To run all feature files in a directory

In the Project tool window, right-click the directory where the feature files are stored.
On the context menu of the directory, choose Run all features in .

Does Android Studio not inherit this functionality?

from cleanguitestarchitecture.

sebaslogen avatar sebaslogen commented on June 2, 2024

In Android Studio, run connectedAndroidTest in the right Gradle tab and then edit the run configuration to add under the Script parameters something like -Ptags="@login-scenarios,@kitkat"

Let me know if it works.

As for the IntelliJ feature I have no info.

from cleanguitestarchitecture.

ArunaBalasubramanian avatar ArunaBalasubramanian commented on June 2, 2024

Hello,
The connectedAndroidTest with script parameters doesn't seem to filter my scenarios based on tags.
Should the build.gradle file be instructed about the usage of -Ptags parameter?

My cucumber runner looks like below, I do not use a CucumberTestCase file that has other added properties.

@CucumberOptions(features = "features")
public class CucumberInstrumentationRunner extends MonitoringInstrumentation {
private final CucumberInstrumentationCore instrumentationCore = new
CucumberInstrumentationCore(this);

@Override
public void onCreate(final Bundle bundle) {
    super.onCreate(bundle);
    instrumentationCore.create(bundle);
    start();
}

@Override
public void onStart() {
    waitForIdleSync();
    instrumentationCore.start();
}

}

from cleanguitestarchitecture.

sebaslogen avatar sebaslogen commented on June 2, 2024

@ArunaBalasubramanian the -Ptags is already handled in the build.gradle here, so I'm not sure what is the difference between your configuration and what @willpowr has already running.

Maybe try restoring the CucumberTestCase class and see if that helps.

from cleanguitestarchitecture.

ArunaBalasubramanian avatar ArunaBalasubramanian commented on June 2, 2024

Thanks @sebaslogen for your response.

build.zip

This is my build.gradle. Do you see anything that needs change?
Adding a CucumberTestCase is throwing me "cucumber.runtime.CucumberException: No CucumberOptions annotation". I tried solving using #3, but didn't help.

from cleanguitestarchitecture.

sebaslogen avatar sebaslogen commented on June 2, 2024

@ArunaBalasubramanian I don't see anything wrong with your build.gradle

As for the CucumberTestCase the easiest way is to copy the files and structure under androidTest folder of this sample project, start by reducing the feature and steps to a simple step opening the app and then get it running.

from cleanguitestarchitecture.

amesandy-zz avatar amesandy-zz commented on June 2, 2024

how do you add the features(android test) folder on assets directory?

from cleanguitestarchitecture.

sebaslogen avatar sebaslogen commented on June 2, 2024

@amesandy you can create the folder structure using the file explorer of your OS. Just follow the same path structure as the code in this repository

from cleanguitestarchitecture.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.