Skip to content

Commit d2668e3

Browse files
upgrade gradle
1 parent 8e08ea9 commit d2668e3

10 files changed

Lines changed: 89 additions & 31 deletions

File tree

.github/workflows/android-emulator-test.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ on:
44
workflows: ["Android CI"]
55
types:
66
- completed
7-
branches:
8-
- main
97
workflow_dispatch: {}
108

119
jobs:

AGENTS.md

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ WiFiAnalyzer is an Android application for analyzing WiFi networks. It helps use
2525
## Project Structure
2626

2727
```
28-
app/src/main/kotlin/ # Main source code
29-
app/src/test/kotlin/ # Unit tests
28+
app/src/main/kotlin/ # Main application source code
29+
app/src/test/kotlin/ # Unit tests
3030
app/src/androidTest/kotlin/ # Android instrumentation tests
3131
```
3232

@@ -75,30 +75,44 @@ All new features and bug fixes MUST include unit tests.
7575

7676
### Test File Naming
7777

78-
Test files follow the pattern `[ClassName]Test.kt`
78+
Test files use several patterns, including but not limited to:
79+
- `[ClassName]Test.kt`
80+
- `[ClassName]InstrumentedTest.kt`
81+
- `[ClassName]IntegrationTest.kt`
82+
- `[ClassName]ParameterizedTest.kt`
83+
- `[ClassName]TestUtil.kt`
84+
85+
Use the pattern that best describes the test's purpose. Document any deviations from these patterns in your code or pull request to maintain clarity.
7986

8087
### Test Structure (AAA Pattern)
8188

8289
```kotlin
8390
@Test
84-
fun testMethodName() {
91+
fun shouldReturnCorrectVersionNumber() {
8592
// Arrange: Set up test data and mocks
86-
8793
// Act: Execute the code being tested
88-
8994
// Assert: Verify the results
9095
}
9196
```
9297

9398
### Testing Patterns Used
9499

95-
**Mockito with Kotlin extensions:**
100+
// Example imports for test files:
96101
```kotlin
97102
import org.mockito.kotlin.mock
98103
import org.mockito.kotlin.verify
99104
import org.mockito.kotlin.whenever
100105
```
101106

107+
// Example imports for assertions:
108+
```kotlin
109+
import org.assertj.core.api.Assertions.assertThat
110+
111+
assertThat(actual).isEqualTo(expected)
112+
assertThat(actual).isTrue
113+
assertThat(actual).isNotNull()
114+
```
115+
102116
**Test teardown pattern:**
103117
```kotlin
104118
@After
@@ -107,13 +121,34 @@ fun tearDown() {
107121
}
108122
```
109123

110-
**Robolectric for Android components:**
124+
**Robolectric for Android components (use RobolectricUtil helper):**
111125
```kotlin
112-
val activity = Robolectric
113-
.buildActivity(MainActivity::class.java)
114-
.create()
115-
.resume()
116-
.get()
126+
import com.vrem.wifianalyzer.RobolectricUtil
127+
128+
private val mainActivity = RobolectricUtil.INSTANCE.activity
129+
130+
// For fragments:
131+
RobolectricUtil.INSTANCE.startFragment(fragment)
132+
```
133+
134+
## Android Instrumentation Test Conventions
135+
136+
- Instrumentation test files are located in `app/src/androidTest/kotlin/`.
137+
- File names typically follow the pattern `[ClassName]InstrumentedTest.kt`.
138+
- Use the `@RunWith(AndroidJUnit4::class)` annotation for instrumentation tests.
139+
- Access UI components using Espresso or Robolectric as appropriate.
140+
- Example instrumentation test structure:
141+
142+
```kotlin
143+
@RunWith(AndroidJUnit4::class)
144+
class MainActivityInstrumentedTest {
145+
@Test
146+
fun shouldDisplayMainScreen() {
147+
// Arrange: Launch activity
148+
// Act: Interact with UI
149+
// Assert: Verify UI state
150+
}
151+
}
117152
```
118153

119154
## Build Commands

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ dependencies {
4949
testImplementation 'com.googlecode.junit-toolbox:junit-toolbox:2.4'
5050
testImplementation 'junit:junit:4.13.2'
5151
testImplementation 'org.mockito:mockito-core:5.21.0'
52-
testImplementation 'org.mockito.kotlin:mockito-kotlin:6.1.0'
52+
testImplementation 'org.mockito.kotlin:mockito-kotlin:6.2.1'
5353
testImplementation 'org.robolectric:robolectric:4.16'
5454
testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
5555
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
@@ -89,7 +89,7 @@ android {
8989
release {
9090
minifyEnabled = true
9191
shrinkResources = true
92-
proguardFiles getDefaultProguardFile("proguard-android.txt")
92+
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt")
9393
signingConfig
9494
}
9595
debug {

app/build.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Build Properties
2-
#Sat Jan 10 12:10:13 EST 2026
3-
version_build=0
2+
#Sat Jan 17 10:15:29 EST 2026
3+
version_build=1
44
version_major=3
55
version_minor=2
66
version_patch=2

app/src/test/kotlin/com/vrem/wifianalyzer/ActivityUtilsTest.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import org.assertj.core.api.Assertions.assertThat
2727
import org.junit.After
2828
import org.junit.Test
2929
import org.mockito.kotlin.any
30+
import org.mockito.kotlin.doReturn
3031
import org.mockito.kotlin.mock
3132
import org.mockito.kotlin.verify
3233
import org.mockito.kotlin.verifyNoMoreInteractions
@@ -54,8 +55,8 @@ class ActivityUtilsTest {
5455
@Test
5556
fun setupToolbar() {
5657
// setup
57-
whenever<Any>(mainActivity.findViewById(R.id.toolbar)).thenReturn(toolbar)
58-
whenever(mainActivity.supportActionBar).thenReturn(actionBar)
58+
doReturn(toolbar).whenever(mainActivity).findViewById<View>(R.id.toolbar)
59+
doReturn(actionBar).whenever(mainActivity).supportActionBar
5960
// execute
6061
val actual = mainActivity.setupToolbar()
6162
// validate
@@ -70,8 +71,8 @@ class ActivityUtilsTest {
7071
@Test
7172
fun keepScreenOnSwitchOn() {
7273
// setup
73-
whenever(settings.keepScreenOn()).thenReturn(true)
74-
whenever(mainActivity.window).thenReturn(window)
74+
doReturn(true).whenever(settings).keepScreenOn()
75+
doReturn(window).whenever(mainActivity).window
7576
// execute
7677
mainActivity.keepScreenOn()
7778
// validate
@@ -83,8 +84,8 @@ class ActivityUtilsTest {
8384
@Test
8485
fun keepScreenOnSwitchOff() {
8586
// setup
86-
whenever(settings.keepScreenOn()).thenReturn(false)
87-
whenever(mainActivity.window).thenReturn(window)
87+
doReturn(false).whenever(settings).keepScreenOn()
88+
doReturn(window).whenever(mainActivity).window
8889
// execute
8990
mainActivity.keepScreenOn()
9091
// validate

app/src/test/kotlin/com/vrem/wifianalyzer/DrawerNavigationTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class DrawerNavigationTest {
4444
@Before
4545
fun setUp() {
4646
doReturn(actionBarDrawerToggle).whenever(fixture).createDrawerToggle(drawerLayout)
47-
whenever<Any>(mainActivity.findViewById(R.id.drawer_layout)).thenReturn(drawerLayout)
47+
doReturn(drawerLayout).whenever(mainActivity).findViewById<View>(R.id.drawer_layout)
4848
fixture.create()
4949
}
5050

app/src/test/kotlin/com/vrem/wifianalyzer/navigation/availability/BottomNavTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import com.vrem.wifianalyzer.MainActivity
2222
import com.vrem.wifianalyzer.R
2323
import org.junit.After
2424
import org.junit.Test
25+
import org.mockito.kotlin.doReturn
2526
import org.mockito.kotlin.mock
2627
import org.mockito.kotlin.verify
2728
import org.mockito.kotlin.verifyNoMoreInteractions
@@ -40,7 +41,7 @@ class BottomNavTest {
4041
@Test
4142
fun navigationOptionBottomNavOff() {
4243
// setup
43-
whenever<View>(mainActivity.findViewById(R.id.nav_bottom)).thenReturn(view)
44+
doReturn(view).whenever(mainActivity).findViewById<View>(R.id.nav_bottom)
4445
// execute
4546
navigationOptionBottomNavOff(mainActivity)
4647
// validate
@@ -51,7 +52,7 @@ class BottomNavTest {
5152
@Test
5253
fun navigationOptionBottomNavOn() {
5354
// setup
54-
whenever<View>(mainActivity.findViewById(R.id.nav_bottom)).thenReturn(view)
55+
doReturn(view).whenever(mainActivity).findViewById<View>(R.id.nav_bottom)
5556
// execute
5657
navigationOptionBottomNavOn(mainActivity)
5758
// validate

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ buildscript {
2828
gradlePluginPortal() // Added for plugin resolution
2929
}
3030
dependencies {
31-
classpath 'com.android.tools.build:gradle:8.13.2'
31+
classpath 'com.android.tools.build:gradle:9.0.0'
3232
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
3333
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
3434
classpath "com.github.ben-manes:gradle-versions-plugin:0.53.0"

gradle.properties

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,27 @@ android.nonFinalResIds=true
2121
android.jetifier.ignorelist=bcprov-jdk15on
2222

2323
# Kotlin code style
24-
kotlin.code.style=official
24+
kotlin.code.style=official
25+
26+
# Remove these lines entirely (use new defaults):
27+
# new default is false
28+
android.defaults.buildfeatures.resvalues=true
29+
# new default is true
30+
android.sdk.defaultTargetSdkToCompileSdkIfUnset=false
31+
# new default is true
32+
android.enableAppCompileTimeRClass=false
33+
# new default is true
34+
android.usesSdkInManifest.disallowed=false
35+
# new default is true
36+
android.builtInKotlin=false
37+
# new default is true
38+
android.newDsl=false
39+
40+
# Keep these if needed for your project:
41+
android.uniquePackageNames=false
42+
android.dependency.useConstraints=true
43+
android.r8.strictFullModeForKeepRules=false
44+
android.r8.optimizedResourceShrinking=false
45+
46+
# Add this to suppress the constraint warning:
47+
android.generateSyncIssueWhenLibraryConstraintsAreEnabled=false

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-8.14.2-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip

0 commit comments

Comments
 (0)