Last active
February 5, 2023 22:03
-
-
Save ArunYogeshwaran/cf732dc584caf79f8007ac510c683dd2 to your computer and use it in GitHub Desktop.
Example of a unit test with a descriptive name
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
// Unit under test | |
fun fetchJobs(user: User) : List<Job> { | |
if (user.isRegistered()) { | |
return emptyList() | |
} else { | |
val jobs = jobsApi.getJobs(user) | |
return jobs | |
} | |
} | |
// A test with a non-descriptive name | |
@Test | |
fun `test fetch jobs`() { | |
// Test arrangements and setup | |
val user = getRegisteredTestUser() | |
val jobs = jobsSource.fetchJobs(user) | |
assertThat(jobs).isEqualTo(expectedJobs) | |
} | |
// A test with a descriptive name | |
@Test | |
fun `fetch jobs with registered user verify valid list returned`() { | |
// Test arrangements and setup | |
val user = getRegisteredTestUser() | |
val jobs = jobsSource.fetchJobs(user) | |
assertThat(jobs).isEqualTo(expectedJobs) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment