Merge pull request #53 from fknives/review-core-integration

Proof read core integration instruction set
This commit is contained in:
Gergely Hegedis 2022-01-28 13:06:33 +02:00 committed by GitHub
commit 1310356207
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View file

@ -130,7 +130,7 @@ We are still missing `mockServerScenarioSetupExtensions` this will be our TestEx
`MockServerScenarioSetupExtensions` is declared in the `:network` test module. `MockServerScenarioSetupExtensions` is declared in the `:network` test module.
However we are still able to import it. However we are still able to import it.
That's because of [java-test-fixtures](https://docs.gradle.org/current/userguide/java_testing.html#sec:java_test_fixtures) plugin. It is can be used to depend on a specific test module "textFixtures". That's because of [java-test-fixtures](https://docs.gradle.org/current/userguide/java_testing.html#sec:java_test_fixtures) plugin. It can be used to depend on a specific test module "textFixtures".
Check out the build.gradle's to see how that's done. Check out the build.gradle's to see how that's done.
This can be useful to share some static Test Data, or extensions in our case. This can be useful to share some static Test Data, or extensions in our case.
@ -153,13 +153,14 @@ As usual, we start with the simplest test. Let's verify that if the session obje
```kotlin ```kotlin
@DisplayName("GIVEN no session saved WHEN checking if user is logged in THEN they are not") @DisplayName("GIVEN no session saved WHEN checking if user is logged in THEN they are not")
@Test @Test
fun withoutSessionTheUserIsNotLoggedIn() = runTest { fun withoutSessionTheUserIsNotLoggedIn() = runTest {
fakeUserDataLocalStorage.session = null fakeUserDataLocalStorage.session = null
val actual = isUserLoggedInUseCase.invoke() val actual = isUserLoggedInUseCase.invoke()
Assertions.assertFalse(actual, "User is expected to be not logged in") Assertions.assertFalse(actual, "User is expected to be not logged in")
verifyZeroInteractions(mockSessionExpirationListener) verifyZeroInteractions(mockSessionExpirationListener)
}
``` ```
### 2. `loginSuccess` ### 2. `loginSuccess`
@ -251,7 +252,7 @@ fun networkInputError(authScenario: AuthScenario) = runTest {
We have one more expected error type, but this comes from the NetworkResponse. We could add it as parametrized test, but for the sake of readability, let's just keep it separate. We have one more expected error type, but this comes from the NetworkResponse. We could add it as parametrized test, but for the sake of readability, let's just keep it separate.
Thi is really similar to the `networkInputError`, the differences are that this is not parametrized, we use `AuthScenario.InvalidCredentials` response and we expect `Answer.Success(LoginStatus.INVALID_CREDENTIALS)` This is really similar to the `networkInputError`, the differences are that this is not parametrized, we use `AuthScenario.InvalidCredentials` response and we expect `Answer.Success(LoginStatus.INVALID_CREDENTIALS)`
So together: So together:
```kotlin ```kotlin

View file

@ -44,7 +44,7 @@ class CodeKataAuthIntegrationTest : KoinTest {
@BeforeEach @BeforeEach
fun setup() { fun setup() {
mockSessionExpirationListener = mock() // we are using mock, since it only has 1 function so we just want to verify if it's called mockSessionExpirationListener = mock() // we are using mock, since it only has 1 function so we just want to verify if its called
fakeFavouriteContentLocalStorage = FakeFavouriteContentLocalStorage() fakeFavouriteContentLocalStorage = FakeFavouriteContentLocalStorage()
fakeUserDataLocalStorage = FakeUserDataLocalStorage(null) fakeUserDataLocalStorage = FakeUserDataLocalStorage(null)
startKoin { startKoin {