-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: Add integration(e2e) test #424
Changes from all commits
7746328
1e013b7
e358a5f
48c4d68
fa59619
2c9e3ba
ba7b480
c7ad39a
474d658
822b895
240f9c9
1441a0b
f3aa6a4
8790e86
b50e444
4c96920
829dff3
14f34a1
e274ba9
d4f2166
2f76e6f
01a80f3
7f62dd6
a9cc4ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,7 +98,8 @@ def enableSeparateBuildPerCPUArchitecture = false | |
def enableProguardInReleaseBuilds = false | ||
|
||
android { | ||
compileSdkVersion 28 | ||
compileSdkVersion rootProject.ext.compileSdkVersion | ||
buildToolsVersion rootProject.ext.buildToolsVersion | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
|
@@ -107,7 +108,7 @@ android { | |
|
||
defaultConfig { | ||
applicationId "io.parity.signer" | ||
minSdkVersion 16 | ||
minSdkVersion 18 | ||
missingDimensionStrategy 'react-native-camera', 'general' | ||
targetSdkVersion 28 | ||
versionCode 309 | ||
|
@@ -119,6 +120,8 @@ android { | |
pickFirst 'lib/x86_64/libjsc.so' | ||
pickFirst 'lib/arm64-v8a/libjsc.so' | ||
} | ||
testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type | ||
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' | ||
} | ||
signingConfigs { | ||
release { | ||
|
@@ -146,6 +149,8 @@ android { | |
release { | ||
minifyEnabled enableProguardInReleaseBuilds | ||
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" | ||
// Detox-specific additions to pro-guard | ||
// proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we remove this stray comment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These code is needed once ProGuard is Enabled, I will add one line comment above. |
||
} | ||
} | ||
// applicationVariants are e.g. debug, release | ||
|
@@ -179,6 +184,16 @@ dependencies { | |
} else { | ||
implementation 'org.webkit:android-jsc:+' | ||
} | ||
androidTestImplementation('com.wix:detox:+') { transitive = true } | ||
androidTestImplementation 'junit:junit:4.12' | ||
} | ||
|
||
configurations.all { | ||
resolutionStrategy { | ||
// the line below is required for Detox since version 14.5.0; | ||
// it should removed as soon as the project compiles without it | ||
force 'androidx.annotation:annotation:1.0.0' | ||
} | ||
} | ||
|
||
// Run this once to be able to run the application with BUCK | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.parity.signer; | ||
|
||
import com.wix.detox.Detox; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
import androidx.test.filters.LargeTest; | ||
import androidx.test.rule.ActivityTestRule; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
@LargeTest | ||
public class DetoxTest { | ||
|
||
@Rule | ||
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false); | ||
|
||
@Test | ||
public void runDetoxTests() { | ||
Detox.runTests(mActivityRule); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,19 +3,19 @@ | |
buildscript { | ||
ext { | ||
buildToolsVersion = "28.0.3" | ||
minSdkVersion = 16 | ||
minSdkVersion = 18 | ||
compileSdkVersion = 28 | ||
targetSdkVersion = 28 | ||
supportLibVersion = "28.0.0" | ||
kotlinVersion = '1.3.41' | ||
} | ||
|
||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath('com.android.tools.build:gradle:3.4.2') | ||
|
||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" | ||
// NOTE: Do not place your application dependencies here; they belong | ||
// in the individual module build.gradle files | ||
} | ||
|
@@ -35,6 +35,10 @@ allprojects { | |
// Android JSC is installed from npm | ||
url("$rootDir/../node_modules/jsc-android/dist") | ||
} | ||
maven { | ||
// All of Detox' artifacts are provided via the npm module | ||
url "$rootDir/../node_modules/detox/Detox-android" | ||
} | ||
} | ||
} | ||
|
||
|
@@ -47,4 +51,12 @@ subprojects { | |
} | ||
} | ||
} | ||
} | ||
afterEvaluate {project -> | ||
if (project.hasProperty("android")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fix the dependency version problem, e.g. in |
||
android { | ||
compileSdkVersion 28 | ||
buildToolsVersion "28.0.3" | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"setupFilesAfterEnv": ["./init.js"], | ||
"testEnvironment": "node", | ||
"reporters": ["detox/runners/jest/streamlineReporter"], | ||
"verbose": true | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import testIDs from "./testIDs"; | ||
|
||
describe('Load test', () => { | ||
it('should have account list screen', async () => { | ||
await expect(element(by.id(testIDs.TacScreen.tacView))).toBeVisible(); | ||
await element(by.id(testIDs.TacScreen.agreePrivacyButton)).tap(); | ||
await element(by.id(testIDs.TacScreen.agreeTacButton)).tap(); | ||
await element(by.id(testIDs.TacScreen.nextButton)).tap(); | ||
await expect(element(by.id(testIDs.AccountListScreen.accountList))).toBeVisible(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const detox = require('detox'); | ||
const config = require('../package.json').detox; | ||
const adapter = require('detox/runners/jest/adapter'); | ||
const specReporter = require('detox/runners/jest/specReporter'); | ||
|
||
// Set the default timeout | ||
jest.setTimeout(120000); | ||
jasmine.getEnv().addReporter(adapter); | ||
|
||
// This takes care of generating status logs on a per-spec basis. By default, jest only reports at file-level. | ||
// This is strictly optional. | ||
jasmine.getEnv().addReporter(specReporter); | ||
|
||
beforeAll(async () => { | ||
await detox.init(config); | ||
}); | ||
|
||
beforeEach(async () => { | ||
await adapter.beforeEach(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await adapter.afterAll(); | ||
await detox.cleanup(); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const testIDs = { | ||
TacScreen: { | ||
tacView: 'tac_view', | ||
agreeTacButton: 'tac_agree', | ||
agreePrivacyButton: 'tac_privacy', | ||
nextButton: 'tac_next' | ||
}, | ||
AccountListScreen: { | ||
accountList: 'accountList', | ||
} | ||
}; | ||
|
||
export default testIDs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minimal version for Detox