mirror of
https://github.com/hmalik144/sumtest.git
synced 2026-03-18 07:35:53 +00:00
Android cucumber setup to run a sample feature file
This commit is contained in:
5
app/src/androidTest/assets/features/sample.feature
Normal file
5
app/src/androidTest/assets/features/sample.feature
Normal file
@@ -0,0 +1,5 @@
|
||||
Feature: Sample feature file
|
||||
|
||||
@sample_test
|
||||
Scenario: Successful login
|
||||
Given I start the application
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.example.sumtest
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.example.sumtest", appContext.packageName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.example.sumtest.steps
|
||||
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.example.sumtest.SumActivity
|
||||
import io.cucumber.java.Before
|
||||
import io.cucumber.java.en.Given
|
||||
import org.junit.Assert
|
||||
|
||||
class SampleSteps {
|
||||
|
||||
private lateinit var mActivityScenarioRule: ActivityScenario<*>
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
mActivityScenarioRule = ActivityScenario.launch(SumActivity::class.java)
|
||||
}
|
||||
|
||||
@Given("I start the application")
|
||||
fun I_start_the_application() {
|
||||
mActivityScenarioRule.moveToState(Lifecycle.State.STARTED)
|
||||
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
Assert.assertEquals("com.example.sumtest", appContext.packageName)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.example.sumtest.test
|
||||
|
||||
import io.cucumber.junit.CucumberOptions
|
||||
|
||||
|
||||
@CucumberOptions(
|
||||
features = ["features"],
|
||||
tags = ["@sample_test"],
|
||||
glue = ["com.example.sumtest.steps"]
|
||||
)
|
||||
class CucumberRunner
|
||||
Reference in New Issue
Block a user