Skip to content

Commit a6ce460

Browse files
authored
Merge pull request #6 from browserstack/AASI_53_coverage_report
Coverage Report Readme Update + SDKVersion bumping from 26->30 + AndroidX
2 parents 5858e5f + 57f8c89 commit a6ce460

File tree

9 files changed

+61
-42
lines changed

9 files changed

+61
-42
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
## Setup
1010

1111
* Clone the repo
12+
* Download JDK8 from [here](https://www.oracle.com/in/java/technologies/javase/javase-jdk8-downloads.html)
13+
* Update your JDK location via Project Structure (Android Studio)
14+
* Go to File > Project Structure.
15+
* Select the SDK Location section in the list of the left.
16+
* Enter the absolute path of your installed JDK in the text box.
1217
* Build the main application: `./gradlew assemble` (apk will be generated in the `app/build/outputs/apk/debug/` directory)
1318
* Build the test application: `./gradlew assembleAndroidTest` (apk will be generated in the `app/build/outputs/apk/androidTest/debug/` directory)
1419
* Upload both the apk files to BrowserStack and start a session. Refer our documentation for details: [Using Espresso with BrowserStack](https://www.browserstack.com/app-automate/espresso/get-started)
@@ -21,3 +26,9 @@
2126
* [Browsers & mobile devices for app-automate testing on BrowserStack](https://www.browserstack.com/list-of-browsers-and-platforms?product=app_automate)
2227
* [Using REST API to access information about your builds via the command-line interface](https://www.browserstack.com/app-automate/rest-api)
2328
* [Using Espresso with BrowserStack](https://www.browserstack.com/app-automate/espresso/get-started)
29+
* [Generating JUnit XML report or Test coverage report using Espresso with BrowserStack](https://www.browserstack.com/docs/app-automate/espresso/view-test-reports)
30+
example:
31+
curl -u "<username>:<password>" \
32+
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/build" \
33+
-d '{"app": "bs://<app_id>", "testSuite": "bs://<test_suite_id>", "devices": ["Google Pixel-8.0"], "coverage": true, "enableSpoonFramework": true }' \
34+
-H "Content-Type: application/json"

app/build.gradle

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ buildscript {
1515
}
1616

1717
android {
18-
compileSdkVersion 26
18+
compileSdkVersion 30
1919
dataBinding.enabled = true
2020

2121
defaultConfig {
2222
applicationId "com.sample.browserstack.samplecalculator"
2323
minSdkVersion 15
24-
targetSdkVersion 26
24+
targetSdkVersion 30
2525
versionCode 1
2626
versionName "1.0"
27-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
27+
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
2828
}
2929
buildTypes {
3030
release {
@@ -35,16 +35,21 @@ android {
3535
testCoverageEnabled true
3636
}
3737
}
38+
compileOptions {
39+
sourceCompatibility JavaVersion.VERSION_1_8
40+
targetCompatibility JavaVersion.VERSION_1_8
41+
}
3842
}
3943

4044
dependencies {
4145
implementation fileTree(dir: 'libs', include: ['*.jar'])
42-
implementation 'com.android.support:appcompat-v7:26.1.0'
43-
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
44-
testImplementation 'junit:junit:4.12'
45-
androidTestImplementation 'com.android.support.test:runner:1.0.1'
46-
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
46+
implementation 'androidx.appcompat:appcompat:1.0.0'
47+
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
48+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
4749
androidTestImplementation 'com.squareup.spoon:spoon-client:1.7.1'
50+
androidTestImplementation 'androidx.test:rules:1.1.1'
51+
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
52+
testImplementation 'junit:junit:4.12'
4853
}
4954

5055
spoon {

app/src/androidTest/java/com/sample/browserstack/samplecalculator/EnsureInputTests.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
package com.sample.browserstack.samplecalculator;
22

3-
import android.support.test.filters.SmallTest;
4-
import android.support.test.rule.ActivityTestRule;
5-
import android.support.test.runner.AndroidJUnit4;
3+
import androidx.test.filters.SmallTest;
4+
import androidx.test.rule.ActivityTestRule;
5+
import androidx.test.ext.junit.runners.AndroidJUnit4;
6+
7+
import com.squareup.spoon.Spoon;
68

79
import org.junit.Before;
810
import org.junit.Rule;
911
import org.junit.Test;
1012
import org.junit.runner.RunWith;
1113

12-
import static android.support.test.espresso.Espresso.onView;
13-
import static android.support.test.espresso.action.ViewActions.click;
14-
import static android.support.test.espresso.assertion.ViewAssertions.matches;
15-
import static android.support.test.espresso.matcher.ViewMatchers.withId;
16-
import static android.support.test.espresso.matcher.ViewMatchers.withText;
17-
import com.squareup.spoon.Spoon;
14+
import static androidx.test.espresso.Espresso.onView;
15+
import static androidx.test.espresso.action.ViewActions.click;
16+
import static androidx.test.espresso.assertion.ViewAssertions.matches;
17+
import static androidx.test.espresso.matcher.ViewMatchers.withId;
18+
import static androidx.test.espresso.matcher.ViewMatchers.withText;
1819

1920
/**
2021
* Espresso tests to ensure that editText box is updated appropriately

app/src/androidTest/java/com/sample/browserstack/samplecalculator/EnsureOperationTests.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
package com.sample.browserstack.samplecalculator;
22

3-
import android.support.test.filters.MediumTest;
4-
import android.support.test.rule.ActivityTestRule;
5-
import android.support.test.runner.AndroidJUnit4;
3+
import androidx.test.filters.MediumTest;
4+
import androidx.test.rule.ActivityTestRule;
5+
import androidx.test.ext.junit.runners.AndroidJUnit4;
6+
7+
import com.squareup.spoon.Spoon;
68

79
import org.junit.Before;
810
import org.junit.Rule;
911
import org.junit.Test;
1012
import org.junit.runner.RunWith;
1113

12-
import static android.support.test.espresso.Espresso.onView;
13-
import static android.support.test.espresso.action.ViewActions.click;
14-
import static android.support.test.espresso.assertion.ViewAssertions.matches;
15-
import static android.support.test.espresso.matcher.ViewMatchers.withId;
16-
import static android.support.test.espresso.matcher.ViewMatchers.withText;
17-
import com.squareup.spoon.Spoon;
14+
import static androidx.test.espresso.Espresso.onView;
15+
import static androidx.test.espresso.action.ViewActions.click;
16+
import static androidx.test.espresso.assertion.ViewAssertions.matches;
17+
import static androidx.test.espresso.matcher.ViewMatchers.withId;
18+
import static androidx.test.espresso.matcher.ViewMatchers.withText;
1819

1920
/**
2021
* Espresso tests to ensure that simple operations result in

app/src/androidTest/java/com/sample/browserstack/samplecalculator/EnsureRandomTests.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
package com.sample.browserstack.samplecalculator;
22

3-
import android.support.test.filters.MediumTest;
4-
import android.support.test.rule.ActivityTestRule;
5-
import android.support.test.runner.AndroidJUnit4;
3+
import androidx.test.filters.MediumTest;
4+
import androidx.test.rule.ActivityTestRule;
5+
import androidx.test.ext.junit.runners.AndroidJUnit4;
66

77
import org.junit.Rule;
88
import org.junit.Test;
99
import org.junit.runner.RunWith;
1010

11-
import static android.support.test.espresso.Espresso.onView;
12-
import static android.support.test.espresso.action.ViewActions.click;
13-
import static android.support.test.espresso.assertion.ViewAssertions.matches;
14-
import static android.support.test.espresso.matcher.ViewMatchers.withId;
15-
import static android.support.test.espresso.matcher.ViewMatchers.withText;
11+
import static androidx.test.espresso.Espresso.onView;
12+
import static androidx.test.espresso.action.ViewActions.click;
13+
import static androidx.test.espresso.assertion.ViewAssertions.matches;
14+
import static androidx.test.espresso.matcher.ViewMatchers.withId;
15+
import static androidx.test.espresso.matcher.ViewMatchers.withText;
1616

1717
/**
1818
* Espresso tests to ensure that random operation result are

app/src/androidTest/java/com/sample/browserstack/samplecalculator/ExampleInstrumentedTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.sample.browserstack.samplecalculator;
22

33
import android.content.Context;
4-
import android.support.test.InstrumentationRegistry;
5-
import android.support.test.runner.AndroidJUnit4;
4+
import androidx.test.platform.app.InstrumentationRegistry;
5+
import androidx.test.ext.junit.runners.AndroidJUnit4;
66

77
import org.junit.Test;
88
import org.junit.runner.RunWith;
@@ -17,10 +17,9 @@
1717
@RunWith(AndroidJUnit4.class)
1818
public class ExampleInstrumentedTest {
1919
@Test
20-
public void useAppContext() throws Exception {
20+
public void useAppContext() {
2121
// Context of the app under test.
22-
Context appContext = InstrumentationRegistry.getTargetContext();
23-
22+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
2423
assertEquals("com.sample.browserstack.samplecalculator", appContext.getPackageName());
2524
}
2625
}

app/src/main/java/com/sample/browserstack/samplecalculator/MainActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.sample.browserstack.samplecalculator;
22

3-
import android.databinding.DataBindingUtil;
4-
import android.support.v7.app.AppCompatActivity;
3+
import androidx.databinding.DataBindingUtil;
4+
import androidx.appcompat.app.AppCompatActivity;
55
import android.os.Bundle;
66
import android.view.View;
77

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
# Specifies the JVM arguments used for the daemon process.
1111
# The setting is particularly useful for tweaking memory settings.
12+
android.enableJetifier=true
13+
android.useAndroidX=true
1214
org.gradle.jvmargs=-Xmx1536m
1315

1416
# When configured, Gradle will run in incubating parallel mode.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip

0 commit comments

Comments
 (0)