Skip to content

MultiverseLearningProducts/JSE-U6-Async-Activities

Repository files navigation

Unit 6: Testing Environment Setup - Starter

This is the starter template for Unit 6. Your task is to complete the test setup and write a simple passing test.

Task: 6-2-solution

Objective: Add the JUnit 5 dependency to a Gradle project and write a single, simple passing test to confirm the setup is working correctly.

Your Task:

  1. Verify Gradle Configuration: The build.gradle.kts file already has JUnit 5 configured in the test dependencies block.

  2. Complete the Test: Open src/test/java/com/example/testing/ProjectSetupTest.java and complete the testSetupIsWorking() method.

  3. Add Simple Assertions:

    • Use assertTrue(true) to verify the test environment is working
    • Add additional assertions using assertNotNull(), assertEquals(), and assertFalse()
  4. Run the Tests: Execute ./gradlew test from the terminal to see the "BUILD SUCCESSFUL" message.

What You Need to Do:

@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()
}

Expected Outcome:

  • 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

Learning Objectives:

  • Understand JUnit 5 dependency configuration in Gradle
  • Learn basic test structure and annotations
  • Practice running tests with Gradle
  • Verify test environment is working correctly

How to Run

Prerequisites

  • Java 24 or higher
  • Gradle (or use the included wrapper)

Running Tests

# Run all tests
./gradlew test

# Run specific test class
./gradlew test --tests ProjectSetupTest

# Run with verbose output
./gradlew test --info

Running Application

# Run the main application
./gradlew run

Success Criteria

✅ 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

Next Steps

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! 🧪

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published