diff --git a/Home.md b/Home.md index cff1a02..5de94c4 100644 --- a/Home.md +++ b/Home.md @@ -22,3 +22,35 @@ Essentially, this will generate a default minimalistic jet functional SpringBoot # TDD +## myFirstTest + +Let's start with the simplest thing you can imagine: a single test method with a single statement. Create [src/test/java/example/cashcard/CashCardJsonTest.java](http://192.168.8.55:3000/HQLAx/FamilyCashCard/src/commit/5ff71154302523ab5ebd0a291e3f5819aed8fdb9/src/test/java/djmil/cashcard/CashCardJsonTest.java): + +``` java +package example.cashcard; + +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + +public class CashCardJsonTest { + +@Test + public void myFirstTest() { + assertThat(1).isEqualTo(42); + } +} +``` + +The `@Test` annotation is part of the JUnit library, and the `assertThat` method is part of the AssertJ library. Both of these libraries are imported after the package statement. + +A common convention (but not a requirement) is to always use the Test suffix for test classes. We’ve done that here. The full class name CashCardJsonTest.java gives you a clue about the nature of the test we're about to write. + +In true Test-First fashion, we've written a failing test first. It's important to have a failing test first so you can have high confidence that whatever you did to fix the test actually worked. + +Toggle terminal with `ctrl+tilda` and type + +```bash +./gradlew test +``` + +## Testing the Data Contract