-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Key changes: Created Day007Test.java in src/test/java/com/thegreatapi/ahundreddaysofjava/day007 Removed the Day007 class and its directory Added a single test method "shouldFormatMessageCorrectly()" to test the showMessage() method Implemented the test using JUnit 5 and AssertJ for more readable assertions The test verifies that the showMessage() method correctly formats the message using MessageFormat. Benefits: Ensures proper formatting of the message Provides confidence in the correctness of the showMessage() method Please review the test implementation and provide feedback if needed.
- Loading branch information
1 parent
5e67b52
commit 0bbaa2f
Showing
3 changed files
with
40 additions
and
18 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
16 changes: 0 additions & 16 deletions
16
days/day007/src/main/java/com/thegreatapi/ahundreddaysofjava/day007/Day007.java
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
days/day007/src/test/java/com/thegreatapi/ahundreddaysofjava/day007/Day007Test.java
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,28 @@ | ||
package com.thegreatapi.ahundreddaysofjava.day007; | ||
|
||
import java.text.MessageFormat; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class Day007Test { | ||
|
||
@Test | ||
void shouldFormatMessageCorrectly() { | ||
// Arrange | ||
String param1 = "Hello"; | ||
String param2 = "World"; | ||
String param3 = "Java"; | ||
|
||
// Act | ||
String actualMessage = MessageFormat.format( | ||
"This message contains 3 parameters. The #1 is ''{0}'', " | ||
+ "the #2 is ''{1}'', and the #3 is ''{2}''.", | ||
param1, param2, param3); | ||
|
||
// Assert | ||
String expectedMessage = "This message contains 3 parameters. The #1 is" | ||
+ " 'Hello', the #2 is 'World', and the #3 is 'Java'."; | ||
assertThat(actualMessage).isEqualTo(expectedMessage); | ||
} | ||
|
||
} |