Skip to content
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

Yuval coverage report #138

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fd65561
adding support for coverage report
Jun 18, 2024
4c35b6a
Create codecov-report.yml
yuval-sentry Jun 18, 2024
4154fd8
Update codecov-report.yml
yuval-sentry Jun 18, 2024
d5f8025
update jacoco config
Jun 18, 2024
ce8158e
Merge branch 'yuval-coverage-report' of github.com:sentry-demos/andro…
Jun 18, 2024
1cb62d4
update codecov config
Jun 18, 2024
e49c5b5
adding tests
Jun 18, 2024
9c8e2ce
Update codecov-report.yml
yuval-sentry Jun 18, 2024
163b2fd
Update codecov-report.yml
yuval-sentry Jun 21, 2024
43dfda5
Update codecov-report.yml
yuval-sentry Jun 21, 2024
d28289e
removing file
Jun 21, 2024
0d9bc76
Merge branch 'yuval-coverage-report' of github.com:sentry-demos/andro…
Jun 21, 2024
58c7809
Update codecov-report.yml
yuval-sentry Jun 21, 2024
9788459
Update codecov-report.yml
yuval-sentry Jun 21, 2024
052bf5f
Update codecov-report.yml
yuval-sentry Jun 21, 2024
b75ede9
Update codecov-report.yml
yuval-sentry Jun 21, 2024
62c0b57
updating build.gradle
Jun 21, 2024
a3cf79c
Merge branch 'yuval-coverage-report' of github.com:sentry-demos/andro…
Jun 21, 2024
976d871
Update codecov-report.yml
yuval-sentry Jun 21, 2024
a28f303
removing unnecessary dependency
Jun 21, 2024
22df8e1
Merge branch 'yuval-coverage-report' of github.com:sentry-demos/andro…
Jun 21, 2024
14a1d54
Update codecov-report.yml
yuval-sentry Jun 21, 2024
36b6dca
Update codecov-report.yml
yuval-sentry Jun 21, 2024
68a5bdc
Update codecov-report.yml
yuval-sentry Jun 21, 2024
dc8e34a
Update codecov-report.yml
yuval-sentry Jun 21, 2024
a2835eb
make sure report is always being generated
Jun 21, 2024
6641709
Merge branch 'yuval-coverage-report' of github.com:sentry-demos/andro…
Jun 21, 2024
7a718b8
update tests
Jun 28, 2024
6afb3e1
add tests
Jun 28, 2024
fa36220
Merge branch 'main' into yuval-coverage-report
sdzhong Jul 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update jacoco config
Loaner authored and Loaner committed Jun 18, 2024
commit d5f80250d01e11aa1d444a38fc8d7f69416f58ab
11 changes: 9 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@ jacoco {
}

task jacocoTestReport(type: JacocoReport) {
dependsOn 'testDebugUnitTest' // Use 'testDebugUnitTest' for unit tests in the debug build type
dependsOn 'connectedDebugAndroidTest' // Use 'testDebugUnitTest' for unit tests in the debug build type

reports {
xml.enabled = true
@@ -113,7 +113,7 @@ task jacocoTestReport(type: JacocoReport) {

sourceDirectories.setFrom(files([mainSrc]))
classDirectories.setFrom(files([debugTree]))
executionData.setFrom(fileTree(dir: "${buildDir}/jacoco", includes: ["testDebugUnitTest.exec"]))
executionData.setFrom(fileTree(dir: "${buildDir}/outputs/code_coverage/debugAndroidTest/connected", includes: ["*.ec"]))
}

dependencies {
@@ -127,9 +127,16 @@ dependencies {
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
implementation 'junit:junit:4.12'
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'androidx.test:core:1.5.0'
implementation 'androidx.test.ext:junit:1.1.5'
implementation 'androidx.test.espresso:espresso-core:3.5.1'
def fragment_version = "1.5.6"
// Java language implementation
implementation "androidx.fragment:fragment:$fragment_version"
implementation 'androidx.test:rules:1.4.0'
implementation 'org.mockito:mockito-core:3.11.2'
implementation 'org.mockito:mockito-android:3.11.2'
//implementation 'io.sentry:sentry-android:5.4.0'

// Warning: upgrading the room version beyond 2.0.0 may
// cause errors running automated Saucelabs tests that generate data.
112 changes: 107 additions & 5 deletions app/src/main/java/com/example/vu/android/MainActivityTest.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,113 @@
package com.example.vu.android;

import static org.junit.Assert.*;
import android.content.Intent;

//import androidx.test.core.app.ActivityScenario;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import androidx.test.espresso.Espresso;
import androidx.test.espresso.action.ViewActions;
import androidx.test.espresso.assertion.ViewAssertions;
import androidx.test.espresso.matcher.ViewMatchers;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import io.sentry.Sentry;

@RunWith(AndroidJUnit4.class)
public class MainActivityTest {

@org.junit.Test
public void dummyFunction() {
assertTrue(MainActivity.dummyFunction(false));
@Rule
public ActivityTestRule<MainActivity> activityRule =
new ActivityTestRule<>(MainActivity.class);

@Test
public void testUnhandledArithmeticException() {
Espresso.onView(ViewMatchers.withId(R.id.div_zero))
.perform(ViewActions.click());

// You might need to handle the exception and verify it was captured by Sentry
// Example: verify that Sentry captured the ArithmeticException
}

@Test
public void testUnhandledNegativeArraySizeException() {
Espresso.onView(ViewMatchers.withId(R.id.negative_index))
.perform(ViewActions.click());

// You might need to handle the exception and verify it was captured by Sentry
// Example: verify that Sentry captured the NegativeArraySizeException
}

@Test
public void testHandledArrayIndexOutOfBoundsException() {
Espresso.onView(ViewMatchers.withId(R.id.handled_exception))
.perform(ViewActions.click());

// Verify that Sentry captured the ArrayIndexOutOfBoundsException
}

@Test
public void testANRButton() {
Espresso.onView(ViewMatchers.withId(R.id.anr))
.perform(ViewActions.click());

// Verify that the UI is frozen (ANR)
}

@Test
public void testNativeCrash() {
Espresso.onView(ViewMatchers.withId(R.id.native_crash))
.perform(ViewActions.click());

// Verify that the native crash occurred
}
}

@Test
public void testNativeMessage() {
Espresso.onView(ViewMatchers.withId(R.id.native_message))
.perform(ViewActions.click());

// Verify that the native message was handled
}

@Test
public void testError404() {
Espresso.onView(ViewMatchers.withId(R.id.error_404))
.perform(ViewActions.click());

// Verify that the HTTP request was made
}

@Test
public void testSlowRegexIssue() {
Espresso.onView(ViewMatchers.withId(R.id.slow_regex))
.perform(ViewActions.click());

// Verify that the slow regex performance issue was logged
}

@Test
public void testSlowImageDecodingIssue() {
Espresso.onView(ViewMatchers.withId(R.id.slow_image_decoding))
.perform(ViewActions.click());

// Verify that the slow image decoding performance issue was logged
}

@Test
public void testSlowJsonDecodingIssue() {
Espresso.onView(ViewMatchers.withId(R.id.slow_json_decoding))
.perform(ViewActions.click());

// Verify that the slow json decoding performance issue was logged
}

// @Test
// public void testDummyFunction() {
// boolean result = MainActivity.dummyFunction(false);
// assertTrue(result);
// }
}
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -19,14 +19,14 @@ plugins {
id 'jacoco'
}

//android {
// android {
// // Your existing configuration
// buildTypes {
// debug {
// testCoverageEnabled = true
// }
// }
//}
// }

jacoco {
toolVersion = "0.8.5"