This is the starter template for Unit 6. Your task is to complete the test setup and write a simple passing test.
Objective: Add the JUnit 5 dependency to a Gradle project and write a single, simple passing test to confirm the setup is working correctly.
-
Verify Gradle Configuration: The
build.gradle.ktsfile already has JUnit 5 configured in the test dependencies block. -
Complete the Test: Open
src/test/java/com/example/testing/ProjectSetupTest.javaand complete thetestSetupIsWorking()method. -
Add Simple Assertions:
- Use
assertTrue(true)to verify the test environment is working - Add additional assertions using
assertNotNull(),assertEquals(), andassertFalse()
- Use
-
Run the Tests: Execute
./gradlew testfrom the terminal to see the "BUILD SUCCESSFUL" message.
@Test
public void testSetupIsWorking() {
// TODO: Add a simple assertion to verify the test environment is working
// Hint: Use assertTrue(true) to confirm the setup is working
// TODO: Add additional verification that we can use other assertion methods
// Hint: Try assertNotNull(), assertEquals(), and assertFalse()
}- The test should compile without errors
- The test should pass when run
- You should see "BUILD SUCCESSFUL" when running
./gradlew test - The test environment should be ready for real testing
- Understand JUnit 5 dependency configuration in Gradle
- Learn basic test structure and annotations
- Practice running tests with Gradle
- Verify test environment is working correctly
- Java 24 or higher
- Gradle (or use the included wrapper)
# Run all tests
./gradlew test
# Run specific test class
./gradlew test --tests ProjectSetupTest
# Run with verbose output
./gradlew test --info# Run the main application
./gradlew run✅ JUnit 5 dependency is correctly configured in build.gradle.kts
✅ ProjectSetupTest.java is created in src/test/java directory
✅ Test method is annotated with @Test
✅ Test uses assertTrue(true) to verify setup
✅ ./gradlew test command runs successfully
✅ BUILD SUCCESSFUL message is displayed
After completing this task, you'll be ready for:
- Writing more comprehensive tests
- Testing different types of functionality
- Understanding test-driven development
- Advanced testing concepts and patterns
Good luck with your testing journey! 🧪