Skip to content

Commit

Permalink
Merge pull request #11 from mokhtarmoustafa/Create_test_using_junit_f…
Browse files Browse the repository at this point in the history
…or_bottom_bar_#9

Create test using junit for bottom bar #9
  • Loading branch information
MatheusAlvesPereira authored Jan 1, 2024
2 parents 2a69e95 + 329c585 commit 62fb68e
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 9 deletions.
17 changes: 8 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {

android {
namespace 'com.example.anotoapp'
compileSdk 33
compileSdk 34

defaultConfig {
applicationId "com.example.anotoapp"
Expand Down Expand Up @@ -38,17 +38,16 @@ android {
}

dependencies {
var nav_version = "2.5.3"
var nav_version = "2.7.6"

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

implementation "androidx.core:core-splashscreen:1.0.0"
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation "androidx.core:core-splashscreen:1.0.1"
implementation("androidx.navigation:navigation-fragment-ktx:$nav_version")
implementation("androidx.navigation:navigation-ui-ktx:$nav_version")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.example.anotoapp

import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.ext.junit.rules.ActivityScenarioRule
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import org.junit.Rule
import org.junit.Test


class MainActivityBottomNavigationTest {

@get:Rule
var activityRule = ActivityScenarioRule(
MainActivity::class.java
)

@Test
fun testBottomNavigation() {
runBlocking {

delay(2000)
onView(withId(R.id.frameLayout)).check(matches(isDisplayed()))

// home
onView(withId(R.id.home))
.perform(click())
delay(1000)

//task
onView(withId(R.id.frameLayout)).check(matches(isDisplayed()))
onView(withId(R.id.task))
.perform(click())
delay(1000)

//profile
onView(withId(R.id.frameLayout)).check(matches(isDisplayed()))
onView(withId(R.id.profile))
.perform(click())
delay(1000)

onView(withId(R.id.frameLayout)).check(matches(isDisplayed()))
}
}
}

0 comments on commit 62fb68e

Please sign in to comment.