Giter Site home page Giter Site logo

sebaslogen / cleanguitestarchitecture Goto Github PK

View Code? Open in Web Editor NEW
136.0 136.0 31.0 155 KB

Sample project of Android GUI test automation using Espresso, Cucumber and the Page Object Pattern

License: MIT License

Java 96.88% Gherkin 3.12%
android cucumber espresso pageobject-pattern

cleanguitestarchitecture's Introduction

Hi, I'm Sebastian Lobato Genco

๐Ÿ’ป I'm a software engineer who is passionate about building Android apps.

I โค๏ธ to learn, share and improve myself and the things that I build.


๐Ÿ‘€ Find me


๐Ÿ“ Blog posts


sebaslogen's Github Stats

cleanguitestarchitecture's People

Contributors

lecho avatar nightscape avatar phq avatar sebaslogen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cleanguitestarchitecture's Issues

Is multiple ActivityInstrumentationTestCase2 possible to run under this setup?

Hi

Thanks for the great example, really appreciated!
Just wondering if you have experienced working with multiple ActivityInstrumentationTestCase2 tests. Because later the StepDef might grow to couple hundreds lines easily with all scenarios.

In your case, what if there more screens after welcome screen, how are you going to handle that?
Can they still work under this setup?

Thanks.

How to run multi step definitions file

Thank you for share great examples.
I create 2 file step corresponding to 2 screen (search/result)

But when I run android test It only runs the first file with name sort follows alphabet, the second file not run.

my PR implement: daolq3012/Structure_Android#63

Pls help me resolve this proplem. ๐Ÿ™‡โ€โ™‚๏ธ

Questions : no test were found

Hey,

I try implement to my project, but still have an error "no test were found, Test running failed: Instrumentation run failed due to 'cucumber.runtime.CucumberException'". I already read this thread #3, but still i cannot solve this error. I would greatly appreciate it if you could tell me what I'm doing wrong

Structure folder
screen shot 2017-05-15 at 11 33 37 am

CucumberTestRunner
`@Override
public void onCreate(final Bundle bundle) {
super.onCreate(bundle);
final String tags = sea.olxsulley.BuildConfig.TEST_TAGS;
if (!tags.isEmpty()) {
bundle.putString(CUCUMBER_TAGS_KEY, tags.replaceAll(",", "--").replaceAll("\s", ""));
}
instrumentationCore.create(bundle);
start();
}

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

CucumberOptions
@CucumberOptions( features ="features", glue = {"sea.pits.cucumber.steps"}, format = {"preety", "html:/data/data/com.app.xxxx/cucumber-reports/html-report", "json:/data/data/com.app.xxxx/cucumber-reports/cucumber.json", "junit:/data/data/com.app.xxxx/cucumber-reports/cucumber.xml" }, tags = {"@login-scenarios"} ) class AllTestSuites { }

Steps
` @given("^I see the Entrance or On Boarding page$")
public void i_see_the_Entrance_or_On_Boarding_page() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}

@When("^I swipe entrance$")
public void i_swipe_entrance() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

@Then("^I click skip button$")
public void i_click_skip_button() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}`

Feature File

Feature: Entrance Testing Espresso

@login-scenarios
Scenario: Entrance Test
Given I see the Entrance or On Boarding page
When I swipe entrance
Then I click skip button

Getting pending exception when i run my runner file in cucumber

Here is the error stack trace:
cucumber.api.PendingException: TODO: implement me
at cucumber.runtime.junit.JUnitReporter.addFailure(JUnitReporter.java:150)
at cucumber.runtime.junit.JUnitReporter.addFailureOrIgnoreStep(JUnitReporter.java:138)
at cucumber.runtime.junit.JUnitReporter.result(JUnitReporter.java:98)
at cucumber.runtime.Runtime.runStep(Runtime.java:282)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:102)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at cucumber.runtime.junit.ExamplesRunner.run(ExamplesRunner.java:59)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at cucumber.runtime.junit.ScenarioOutlineRunner.run(ScenarioOutlineRunner.java:53)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:63)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:18)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:70)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:95)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:38)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at cucumber.api.junit.Cucumber.run(Cucumber.java:100)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Here is my Runner file:
import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(
features = "/Users/amruthapenigalapati/eclipse-workspace/corejava/src/Basic_java/CucumberWithJunit/src/test/java/features/Login.feature", //the path of the feature files
glue={"stepDefinitions.LoginStep"}, //the path of the step definition files
plugin = {"pretty","html:test-outout", "json:json_output/cucumber.json", "junit:junit_xml/cucumber.xml"}, //to generate different types of reporting
monochrome = true, //display the console output in a proper readable format
strict = true //it will check if any step is not defined in step definition file
//dryRun = false //to check the mapping is proper between feature file and step def file
)
public class TestRunner {

}

Here is my feature file:
Feature: Ecommerce Application Test

Scenario Outline: Validate Ecommerce Login Page Test

Given ecomm user enters the url
When ecomm user enters the login details "" and ""
Then user logs in successfully

Examples:
| UserName | Password |
| [email protected] | Welcome@123 |
|[email protected] | chitra12112312 |

Here is my step definition file:

import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

import core.ApexBaseTest;
import core.EcommerceConstants;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;

public class LoginStep extends ApexBaseTest implements EcommerceConstants{
static WebDriver driver;
@given("^ecomm user enters the url$")
public static void ecomm_user_enters_the_url() throws Throwable {
ApexBaseTest.setup();
Assert.assertEquals("Welcome to Ez Shop Online" , TITLE);
driver.findElement(By.linkText("ACCOUNT")).click();

}
@When("^ecomm user enters the login details \"([^\"]*)\" and \"([^\"]*)\"$")
public static void ecomm_user_enters_the_login_details(String UserName, String Password) throws Throwable {
	driver.findElement(By.name(EMAIL_NAME_LOCATOR)).sendKeys(UserName);
 	driver.findElement(By.name(PWD_NAME_LOCATOR)).sendKeys(Password);  
 	driver.findElement(By.xpath("/html/body/table/tbody/tr[2]/td/table/tbody/tr/td[2]/table/tbody/tr[4]/td[2]/form/table/tbody/tr[5]/td/a/div")).click();
}
@Then("^user logs in successfully$")
public void user_logs_in_successfully() throws Throwable {
	Assert.assertEquals("You have Logged In successfully.",TITLE2);

}

}

JENIKS: GRADLE: TESTNG: CUCUMBER FEATURE File: testrunner is faling on jekins pipeline only

Hi, i have moved to gradle framework from maven. while running our test with gradle on local machine its getting success but while running the same on jekins with gradle commands i'm facing error on the testng cucumber as below

Gradle suite > Gradle test > regressionSuite.TestRunner.feature[0](Address Verification) FAILED
cucumber.runtime.CucumberException at TestRunner.java:64
Caused by: java.lang.AssertionError at Assert.java:94

lines of the code at those lines is as follows:
@test(groups = "cucumber", description = "Runs Cucumber Feature",
dataProvider = "features") public void feature(CucumberFeatureWrapper cucumberFeature) throws IOException {
testNGCucumberRunner.runCucumber(cucumberFeature.getCucumberFeature()); }

Not able to find the root cause of this issue

commands using on Jekins file are:
sh """

		ls -ltr
		pwd
		echo "gateway is ${gatewayname}"
		chmod 777 ./gradlew
        ./gradlew clean assemble
        ./gradlew test -Dcucumber.options="--tags @$gatewayname"

		"""

Only works for Android 5.1

When running these tests against Android 6.0(emulator) or greater. However this project works great out of the box against 5.1

`Starting 0 tests on Pixel_XL_API_26(AVD) - 8.0.0
Tests on Pixel_XL_API_26(AVD) - 8.0.0 failed: Instrumentation run failed due to 'Process crashed.'

com.android.builder.testing.ConnectedDevice > No tests found.[Pixel_XL_API_26(AVD) - 8.0.0] FAILED
No tests found. This usually means that your test classes are not in the form that your test runner expects (e.g. don't inherit from TestCase or lack @test annotations).
:app:connectedDebugAndroidTest FAILED`

Question : Reset app state between scenario

Hey,
Thank for you repository, it help me a lot to build my test with espresso and cucumber.
I need to reset app stat between some scenario, do you know a way to do this with cucumber and espresso ?

Thanks for all,

Cucumber reports are not generated

After successfully running the tests through the command line using either ./gradlew connectedAndroidTest or ./gradlew connectedCheck it is showing on the Android Monitor the print

Retrieving Cucumber test report to /xx_myProjectPath_xx/CleanGUITestArchitecture/app/build

However, when I review on the project view the cucumber-reports folder it is empty. I am able to creat the report with spoon abd the default with androidTests, though not the case with cucumber-reports.

screen shot 2017-05-23 at 09 29 40

Question - Any instability from left over services between tests?

Hi,

Great repository, just had a quick question. Have you found any instability when working with killing activities outside the standard workflow?
E.g. managing the app life cycle via @testrule @test approach used by the standard Android Test Runner?

Specifically: ActivityFinisher.finishOpenActivities(); // Required for testing App with multiple activities

Full details:
https://jabknowsnothing.wordpress.com/2015/11/05/activitytestrule-espressos-test-lifecycle/

Cheers!

Cucumber Tests to be run in JMeter. Getting "Could not initialize class io.cucumber.core.options.PluginOption"

Hi,

I have a piece of Cucumber + JUNIT + Selenium WebDriver code to be used in JMeter for load testing.
Following is the piece of code:

package runner;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Test;
import cucumber.api.cli.Main;
import pageobjects.alinea.AssetsMetadataPage;

public class TestRunner{
private static Logger Log = LogManager.getLogger(AssetsMetadataPage.class);

public ClassLoader load;

public TestRunner(String str) {
	// TODO Auto-generated constructor stub
	
	this();
}
public TestRunner() {
	// TODO Auto-generated constructor stub
}
// Test method is defined with Cucumber Main run method. 
// "-g" signifies glue code (package where the code is), "-t" signifies the tag.  The location of the feature file which defines the test scripts 


@Test

public void runTest() throws Throwable {
try {

		Main.run(new String[]{"-g", "step_definitions","-t", "@upload", "src/test/resources/features/addcontent.feature"}, ClassLoader.getSystemClassLoader());
		//log.info("Print");
		Log.info("Print");
	} catch (Exception e) {
		e.printStackTrace();
	}
}
// Post Test what the JUNIT test needs to do

}

This is the feature file:
@Upload
Scenario: User upload the image
Given navigate to folder and upload a picture

and imported these jar into the lib folder of jmeter:
cobertura-1.8.jar
mockito-core-3.5.5.jar
cucumber-core-5.7.0.jar
cucumber-java-5.7.0.jar
cucumber-junit-5.7.0.jar
cucumber-jvm-deps-1.0.6.jar
gherkin-15.0.2.jar
selenium-server-standalone-2.53.0.jar

When I try to run from Eclipse, there's no issue, the execution is completed without any glitch.
But when i run this from jmeter getting below error:
Error -- runTest(org.apache.jmeter.protocol.java.sampler.JUnitSampler$AnnotatedTestCase): Could not initialize class io.cucumber.core.options.PluginOption

Am I missing something to add in jmeter for Cucumber options? Thanks in advance for your answers!

Exception while taking the screenshot

hi, i am getting the below exception while taking the screenshot
java.lang.ClassCastException: android.support.v7.view.ContextThemeWrapper cannot be cast to android.app.Activity

It says the error is in SpoonScreenshotAction getActivity method. I am using the latest commit. Please let me know how to resolve it.

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

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

Unable to find element in a webview using onWebView method after SDK 27 update

Hello @sebaslogen ,
The following piece of code returns NULL,
onWebView().withElement(findElement(Locator.XPATH, "//h1[contains(text(),'Login')]"));

This was working fine until I extended the support of my application to OREO (API 27). After upgrading the target version, I have updated my espresso dependency from 2.2 to 3.0.2, post which, onWebview method always return a webview with no elements in it although I can see the webview being loaded in the Android device.

The espresso dependencies have been updated to the following,

androidTestImplementation 'com.android.support.test.espresso:espresso-intents:3.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-web:3.0.2'

I have attached the build.gradle file.
AndroidBuildGradle_Latest.zip

Please let me know if you need any further info on the same.

plugin in Cucumber runner class are showing attribute undefined.

image

Hi,

While i am adding the plugin, under cucumber options are showing me the attribute undefined. Your help/advise will be appreciated.

package test;

import framework.selenium.support.GlobalEng;
import cucumber.api.Scenario;

import org.junit.AfterClass;
import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import com.cucumber.listener.Reporter;

//this is a cucumber annotation dictating the cucumber runner
@RunWith(Cucumber.class)
//this is how we want the results formatted. The only customizable line, different formats can be added or removed. I๏ฟฝve included the most common ones for convenience
@CucumberOptions(
features = "classpath:features" ,
glue = {"test"},
//plugin = {"html:target/cumber-html-report"},
plugin = {"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"},
format={
"pretty", "html:target/results",
"html:target/cucumber-reports/cucumber-pretty",
"json:target/cucumber.json",
"rerun:target/cucumber-reports/rerun.txt"
}
, tags = {
// Write your desire Test Case Annotation Name to Execute the Test.
//"@Broker_Create_Account_End_To_End"
//"@Broker_Portal_End_To_End_Testing"
"@TestCaseB"
//"@Individual_Configure_Account"

	}
	, dryRun = false

	, monochrome = true
	)

//this is an empty class to run with. This needs to remain empty

public class RunCucmberTest {

@AfterClass
public static void shutdownDriver(){

	if(GlobalEng.webDriver !=null){
		GlobalEng.webDriver.quit();
		GlobalEng.webDriver = null;
	}
}
public void setup() {
	

}

}

Getting error: cucumber.runtime.CucumberException: No CucumberOptions annotation

Hey, I've created a sample project based on your example here and now I'm getting the above mentioned exception every time I try to run my test (HelloWorldSteps.java). I would greatly appreciate it if you could tell me what I'm doing wrong. I've attached the relevant classes below. Alternatively, I can also upload my project if you need more information. Let me know. :)

Instrumentation class

public class CucumberTestRunner extends android.support.test.runner.AndroidJUnitRunner {

    public static final String TAG = CucumberTestRunner.class.getSimpleName();

    private final CucumberInstrumentationCore instrumentationCore
            = new CucumberInstrumentationCore(this);

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

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

@CucumberOptions marker class

@CucumberOptions(
    features = "features", // Test scenarios
    glue = {"com.aashreys.cucumberplayground"}, // Steps definitions
    tags= {"@hello-world"}
)
public class CucumberTestCase {
}

Step Definition Class

public class HelloWorldSteps extends ActivityInstrumentationTestCase2<MainActivity> {

    private String helloWorld;

    public HelloWorldSteps(Class<MainActivity> activityClass) {
        super(activityClass);
    }

    public void setUp() throws Exception {
        super.setUp();
        getActivity();
    }

    public void tearDown() throws Exception {
        getActivity().finish();
        super.tearDown();
    }

    @Given("^the text is \"(.+)\"$")
    public void given_the_text_is(String text) {
        helloWorld = text;
    }

    @Then("^the text is \"(.+)\"$")
    public void then_the_text_is(String text) {
        Assert.assertEquals(text, helloWorld);
    }
}

.feature file placed in /src/androidTest/assets/features

Feature: Hello World

  @hello-world
  Scenario: A test to check Hello World!
      Given the text is "Hello World!"
       Then the text should be "Hello World!"

Not a Error but a Question... About Espresso and Cucumber

sorry but i don't get is: what is the different between Espresso and Cucumber? is it the same? I'm not a test kind a guy .. so what's happen with the Espresso Test Recorder in Android Studio... where is this for?

Or is both totally different? Can you please explain that in short terms??
That would be so nice ... Thank you...

Screenshots are no longer working

I am trying to take a screenshot and get a failure error:

Feature Login in the application > Scenario User can login with valid user name and password[Pixel XL - 7.1.2] FAILED 
        java.lang.IllegalStateException: Got a context of class class android.app.ContextImpl and I don't know how to get the Activity from it
        at com.neoranga55.cleanguitestarchitecture.util.SpoonScreenshotAction.getActivity(SpoonScreenshotAction.java:82)
:app:connectedDebugAndroidTest FAILED

Gradle Tasks failed after execution

Either I execute connectedCheck or connectedAndroidTest, after finishing I always retrieve the following exception

`Error:(44, 1) Failed to notify task execution listener.

Cannot run program "adb": error=2, No such file or directory`

It is concerning the task to retrieve Cucumber test reports on Gradle app file configuration. What could I be missing? Maybe I am not executing the tests in a proper manner. Sebas, could you please give me and advice?

Just for the record, I have installed the platform-tools properly. I am not sure if the path /mnt/sdk/cucumber-reports should be modified, though.

Run specific feature

Is it possible to run a specific feature? If I specify the feature: @CucumberOptions(features = "features/login.feature") it runs all features no matter.

Running feature seems to fail.

Is there a different way I should be running the tests? Right-clicking a feature and clicking run ends up failing with the errors:

"
Undefined step: Given I see the login page

Undefined step: When I login with user name "Sebas" and password "passion"
. . .
. .

"

I tried with my own project and yours.

Undefined step(s) returned when executing feature file

Hi,

I've loaded, compiled and run the application successfully on an Android emulator. However when I run the feature file - Feature: defaults, the test fails with the output below.

The tests run successfully when the step definition class StepDefinitions is executed directly via the IDE context menu.

Any ideas on what's going wrong? If you require additional output files I'll be happy to provide them.

Environment:
Windows 10
Android Studio 2.3.2

Thanks,

H

...
Testing started at 12:28 ...

Undefined step: Given I see the login page

Undefined step: When I login with user name "Sebas" and password "passion"

Undefined step: Then I see the welcome page

Undefined step: And the title is "Welcome Sebas"

Undefined step: Given I see the login page

Undefined step: When I login with user name "sebaslogen" and password "passion"

Undefined step: Then I see the welcome page

Undefined step: And the title is "Welcome sebaslogen"

Undefined step: Given I see the login page

Undefined step: When I login with user name "ThirdUser" and password "passion"

Undefined step: Then I see the welcome page

Undefined step: And the title is "Welcome ThirdUser"

3 Scenarios (3 undefined)
12 Steps (12 undefined)
0m0.000s

You can implement missing steps with the snippets below:

@given(...

Nice Work!! But "i_login_with_username_and_password" has an issue... (Maybe)

First of all thank you for this Project ... it's nice and clear ... and very Helpful !!

But :-)
in the Function [i_login_with_username_and_password] the using with the PageObject Pattern is i bit to much coupled i think.

For Example: if i would write a Test called "User can't login without a valid password" (of course i have to change your [UserLoginTask] a bit) i'm not able to use the same [StepDefinitions.java] with a new Function like this:

@Then("^I still see the login screen$") public void something() { mCurrentPage.is(LoginPage.class); }

because the Constructor called in [WelcomePage] just check the ViewID.
May all this can be right and did not understand the context ... but for my perspective should be the constructor Code :

onView(withId(R.id.welcome_activity)).check(matches(isDisplayed()));

somewhere in the StepDefinitions. Or?

Issue java.lang.NoSuchMethodError: com.aventstack.extentreports.reporter.ExtentHtmlReporter.loadXMLConfig(Ljava/io/File;)

I am trying to generate extent report in my Maven+Selenium+Java+Cucumber+Junit project. I have not included testrunner class in my project and the same is been configured in my pom.xml file as below.

com.github.temyers cucumber-jvm-parallel-plugin ${cucumber.jvm.parallel.version} generateRunners generate-test-sources generateRunners com.sample.automation.step_definitions com.api.automation.Hooks ${project.build.directory}/generated-test-sources/cucumber src/test/resources/feature/ target/cucumber-parallel com.vimalselvam.cucumber.listener.ExtentCucumberFormatter ${extentReportDir} html true true ${tags} false simple Parallel{c}IT FEATURE I am trying to include the below code in hooks @after method Reporter.loadXMLConfig(new File("src/test/resource/extent-config.xml")); But i am getting the Issue java.lang.NoSuchMethodError: com.aventstack.extentreports.reporter.ExtentHtmlReporter.loadXMLConfig(Ljava/io/File;)V at com.vimalselvam.cucumber.listener.Reporter.loadXMLConfig error even if the dependencies are added in pom.xml
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>4.0.9</version>
</dependency>

I need help in

  1. How to configure the @BeforeClass and @afterclass methods of TestRunner class in pom.xml without adding TestRunner class in my project.
  2. Include additional step logs in extent report.

Trace -- java.lang.NoSuchMethodError: io.cucumber.tagexpressions.TagExpressionParser: method 'void <init>()' not found

Hi,

I am facing below error while running the test script from jmeter.
Error -- runTest(org.apache.jmeter.protocol.java.sampler.JUnitSampler$AnnotatedTestCase): io.cucumber.tagexpressions.TagExpressionParser: method 'void ()' not found
Trace -- java.lang.NoSuchMethodError: io.cucumber.tagexpressions.TagExpressionParser: method 'void ()' not found
at io.cucumber.core.filter.TagPredicate.(TagPredicate.java:26)
at io.cucumber.core.filter.Filters.(Filters.java:19)
at io.cucumber.core.runtime.Runtime$Builder.build(Runtime.java:215)
at io.cucumber.core.cli.Main.run(Main.java:73)
at runner.TestRunner.runTest(TestRunner.java:31)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.apache.jmeter.protocol.java.sampler.JUnitSampler$AnnotatedTestCase.runTest(JUnitSampler.java:595)
at junit.framework.TestResult.runProtected(TestResult.java:142)
at org.apache.jmeter.protocol.java.sampler.JUnitSampler.sample(JUnitSampler.java:395)
at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:630)
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:558)
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
at java.base/java.lang.Thread.run(Thread.java:834)

Having below snipets of code:
package runner;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Test;

import io.cucumber.core.cli.Main;

public class TestRunner {

public ClassLoader load;

private static Logger Log = LogManager.getLogger(TestRunner.class);

protected TestRunner(String str) {
	// TODO Auto-generated constructor stub
	this();
}

public TestRunner() {
	// TODO Auto-generated constructor stub
}
// Test method is defined with Cucumber Main run method.
// "-g" signifies glue code (package where the code is), "-t" signifies the tag.
// The location of the feature file which defines the test scripts

@Test
public void runTest() throws Throwable {
	try {

		Main.run(new String[] { "-g", "step_definitions", "-t", "@upload",
				"src/test/resources/features/addcontent.feature" }, ClassLoader.getSystemClassLoader());
	Log.info("Print");
		
	} catch (Exception e) {
		e.printStackTrace();
	}
}
// Post Test what the JUNIT test needs to do

}

and added below dependencies in lib folder:
cobertura-2.1.1.jar
tag-expressions-3.0.0.jar
gherkin-15.0.2 (1).jar
cucumber-gherkin-6.5.1.jar
cucumber-plugin-6.5.1.jar
slf4j-api-1.7.9.jar
joda-time-2.10.6.jar
commons-lang3-3.10.jar
commons-codec-1.14.jar
mockito-core-3.5.5.jar
gherkin-15.0.2.jar
cucumber-jvm-deps-1.0.6.jar
cucumber-junit-5.7.0.jar
cucumber-java-5.7.0.jar
cucumber-core-5.7.0.jar
cobertura-1.8.jar

Please help me to solve this issue.

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.