-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate setup for Unit Testing - along with enabling unit testing i…
…n CI/CD pipeline Signed-off-by: Abhijit Naik <[email protected]>
- Loading branch information
1 parent
0f255d3
commit 1fd280b
Showing
5 changed files
with
220 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,10 @@ jobs: | |
- name: Build with Gradle | ||
run: ./gradlew build | ||
|
||
# Runs the entire unit test suite | ||
- name: Run Unit Tests | ||
run: ./gradlew test | ||
|
||
# # Runs a set of commands using the runners shell | ||
# - name: Upload a Build Artifact | ||
# uses: actions/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
app/src/test/java/com/compose/weatherapplite/utils/GenericExtensionsTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.compose.weatherapplite.utils | ||
|
||
import io.mockk.impl.annotations.RelaxedMockK | ||
import java.time.LocalDate | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Assert.assertNotEquals | ||
import org.junit.Test | ||
|
||
class GenericExtensionsTest { | ||
|
||
@RelaxedMockK | ||
private val date = LocalDate.now() | ||
|
||
@RelaxedMockK | ||
private val mockedPastDate = LocalDate.now().minusDays(1) | ||
|
||
@RelaxedMockK | ||
private val mockedFutureDate = LocalDate.now().plusDays(1) | ||
|
||
@Test | ||
fun `toDayOfWeek returns Today for current date`() { | ||
// Action | ||
val result = date.toDayOfWeek() | ||
|
||
// Assert | ||
assertEquals("Today", result) | ||
} | ||
|
||
@Test | ||
fun `toDayOfWeek returns correct day name for past date`() { | ||
// Action | ||
val result = mockedPastDate.toDayOfWeek() | ||
|
||
// Assert | ||
assertNotEquals("Today", result) | ||
} | ||
|
||
@Test | ||
fun `toDayOfWeek returns correct day name for future date`() { | ||
// Action | ||
val result = mockedFutureDate.toDayOfWeek() | ||
|
||
// Assert | ||
assertNotEquals("Today", result) | ||
} | ||
} |
153 changes: 153 additions & 0 deletions
153
app/src/test/java/com/compose/weatherapplite/utils/WeatherTypeExtensionsTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
package com.compose.weatherapplite.utils | ||
|
||
import com.compose.weatherapplite.R | ||
import com.compose.weatherapplite.presentation.model.WeatherType | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
|
||
class WeatherTypeExtensionsTest { | ||
|
||
@Test | ||
fun `toDrawable returns correct drawable for ClearSky`() { | ||
// Action | ||
val result = WeatherType.ClearSky.toDrawable() | ||
|
||
// Assert | ||
assertEquals(R.drawable.vd_clear_sky, result) | ||
} | ||
|
||
@Test | ||
fun `toDrawable returns correct drawable for Overcast`() { | ||
// Action | ||
val result = WeatherType.Overcast.toDrawable() | ||
|
||
// Assert | ||
assertEquals(R.drawable.vd_overcast, result) | ||
} | ||
|
||
@Test | ||
fun `toDrawable returns correct drawable for Foggy`() { | ||
// Action | ||
val result = WeatherType.Foggy.toDrawable() | ||
|
||
// Assert | ||
assertEquals(R.drawable.vd_foggy, result) | ||
} | ||
|
||
@Test | ||
fun `toDrawable returns correct drawable for Drizzle`() { | ||
// Action | ||
val result = WeatherType.Drizzle.toDrawable() | ||
|
||
// Assert | ||
assertEquals(R.drawable.vd_drizzle, result) | ||
} | ||
|
||
@Test | ||
fun `toDrawable returns correct drawable for Rain`() { | ||
// Action | ||
val result = WeatherType.Rain.toDrawable() | ||
|
||
// Assert | ||
assertEquals(R.drawable.vd_rain, result) | ||
} | ||
|
||
@Test | ||
fun `toDrawable returns correct drawable for HeavyRain`() { | ||
// Action | ||
val result = WeatherType.HeavyRain.toDrawable() | ||
|
||
// Assert | ||
assertEquals(R.drawable.vd_heavy_rain, result) | ||
} | ||
|
||
@Test | ||
fun `toDrawable returns correct drawable for SnowFall`() { | ||
// Action | ||
val result = WeatherType.SnowFall.toDrawable() | ||
|
||
// Assert | ||
assertEquals(R.drawable.vd_snowfall, result) | ||
} | ||
|
||
@Test | ||
fun `toDrawable returns correct drawable for Thunderstorm`() { | ||
// Action | ||
val result = WeatherType.Thunderstorm.toDrawable() | ||
|
||
// Assert | ||
assertEquals(R.drawable.vd_thunderstorm, result) | ||
} | ||
|
||
@Test | ||
fun `toAnimatedVectorDrawable returns correct drawable for ClearSky`() { | ||
// Action | ||
val result = WeatherType.ClearSky.toAnimatedVectorDrawable() | ||
|
||
// Assert | ||
assertEquals(R.drawable.avd_clear_sky, result) | ||
} | ||
|
||
@Test | ||
fun `toAnimatedVectorDrawable returns correct drawable for Overcast`() { | ||
// Action | ||
val result = WeatherType.Overcast.toAnimatedVectorDrawable() | ||
|
||
// Assert | ||
assertEquals(R.drawable.avd_overcast, result) | ||
} | ||
|
||
@Test | ||
fun `toAnimatedVectorDrawable returns correct drawable for Foggy`() { | ||
// Action | ||
val result = WeatherType.Foggy.toAnimatedVectorDrawable() | ||
|
||
// Assert | ||
assertEquals(R.drawable.avd_foggy, result) | ||
} | ||
|
||
@Test | ||
fun `toAnimatedVectorDrawable returns correct drawable for Drizzle`() { | ||
// Action | ||
val result = WeatherType.Drizzle.toAnimatedVectorDrawable() | ||
|
||
// Assert | ||
assertEquals(R.drawable.avd_drizzle, result) | ||
} | ||
|
||
@Test | ||
fun `toAnimatedVectorDrawable returns correct drawable for Rain`() { | ||
// Action | ||
val result = WeatherType.Rain.toAnimatedVectorDrawable() | ||
|
||
// Assert | ||
assertEquals(R.drawable.avd_rain, result) | ||
} | ||
|
||
@Test | ||
fun `toAnimatedVectorDrawable returns correct drawable for HeavyRain`() { | ||
// Action | ||
val result = WeatherType.HeavyRain.toAnimatedVectorDrawable() | ||
|
||
// Assert | ||
assertEquals(R.drawable.avd_heavy_rain, result) | ||
} | ||
|
||
@Test | ||
fun `toAnimatedVectorDrawable returns correct drawable for SnowFall`() { | ||
// Action | ||
val result = WeatherType.SnowFall.toAnimatedVectorDrawable() | ||
|
||
// Assert | ||
assertEquals(R.drawable.avd_snowfall, result) | ||
} | ||
|
||
@Test | ||
fun `toAnimatedVectorDrawable returns correct drawable for Thunderstorm`() { | ||
// Action | ||
val result = WeatherType.Thunderstorm.toAnimatedVectorDrawable() | ||
|
||
// Assert | ||
assertEquals(R.drawable.avd_thunderstorm, result) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters