Skip to content

Commit

Permalink
Added missed hasMessageThat() assertion chain
Browse files Browse the repository at this point in the history
  • Loading branch information
Rd4dev committed Aug 20, 2024
1 parent ef924f1 commit a4c48d6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions wiki/Writing-tests-with-good-behavioural-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ fun testDivideNumbers_forZeroDenominator_throwsIllegalArgumentException() {
val exception = assertThrows<IllegalArgumentException> {
divideNumbers(10, 0)
}
assertThat(exception).contains("Denominator cannot be zero")
assertThat(exception).hasMessageThat().contains("Denominator cannot be zero")
}
```
Expand Down Expand Up @@ -577,7 +577,7 @@ fun testBookTickets_withUnavailableSeats_throwsException() {
val exception = assertThrows<IllegalStateException> {
booking.reserveSeat(0)
}
assertThat(exception).contains("No seats are available. Please check other bookings for available seats.")
assertThat(exception).hasMessageThat().contains("No seats are available. Please check other bookings for available seats.")
}
```
Expand Down Expand Up @@ -633,7 +633,7 @@ fun testBookTickets_withUnavailableSeats_throwsException() {
val exception = assertThrows<IllegalStateException> {
booking.reserveSeat(0)
}
assertThat(exception).contains("No seats are available. Please check other bookings for available seats.")
assertThat(exception).hasMessageThat().contains("No seats are available. Please check other bookings for available seats.")
}
```
Expand All @@ -648,7 +648,7 @@ fun testConfirmPayment_withUnsuccessfulPayment_throwsException() {
val exception = assertThrows<IllegalStateException> {
booking.confirmPayment(false)
}
assertThat(exception).contains("Payment not successful. Please try again.")
assertThat(exception).hasMessageThat().contains("Payment not successful. Please try again.")
}
```
Expand Down Expand Up @@ -688,15 +688,15 @@ fun testCalculateDiscount_forNegativePrice_throwsIllegalArgumentException() {
val exception = assertThrows<IllegalArgumentException> {
calculateDiscount(-100.0, 10.0)
}
assertThat(exception).contains("Price and discount cannot be negative")
assertThat(exception).hasMessageThat().contains("Price and discount cannot be negative")
}
@Test
fun testCalculateDiscount_forNegativeDiscount_throwsIllegalArgumentException() {
val exception = assertThrows<IllegalArgumentException> {
calculateDiscount(100.0, -10.0)
}
assertThat(exception).contains("Price and discount cannot be negative")
assertThat(exception).hasMessageThat().contains("Price and discount cannot be negative")
}
```
Expand Down Expand Up @@ -923,7 +923,7 @@ fun testWithdraw_invalidUsername_throwsInvalidCredentialsException() {
val exception = assertThrows<IllegalArgumentException> {
account.withdraw("invalidUser", "password", 200.0)
}
assertThat(exception).contains("Invalid credentials")
assertThat(exception).hasMessageThat().contains("Invalid credentials")
}
@Test
Expand All @@ -947,7 +947,7 @@ fun testWithdraw_withInvalidFileFormat_throwsInvalidFileFormatException() {
val exception = assertThrows<InvalidFileFormatException> {
account.withdraw("user", "password", invalidFile, 200.0)
}
assertThat(exception).contains("Invalid file format")
assertThat(exception).hasMessageThat().contains("Invalid file format")
}
@Test
Expand Down

0 comments on commit a4c48d6

Please sign in to comment.