0Pricing
Groovy & Gradle: JVM Automation and Build Engineering · Lekcja

Raporty z testów i filtrowanie

Generuj i analizuj raporty z testów oraz naucz się filtrować testy w celu ukierunkowanego uruchamiania.

Raporty z testów i filtrowanie to bezpłatna lekcja Groovy & Gradle: JVM Automation and Build Engineering na CoddyKit. To lekcja 2 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Groovy & Gradle: JVM Automation and Build Engineering, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Groovy & Gradle: JVM Automation and Build Engineering zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

Understanding Test Outcomes

Test reports are essential for understanding the health of your project. They provide a clear summary of which tests passed, failed, or were skipped.

This insight helps developers quickly pinpoint issues, track progress, and ensure code quality. Without them, debugging would be much harder!

Automatic HTML Reports

When you run tests with Gradle, it automatically generates an interactive HTML report every time you run your tests. This feature is enabled by default when you apply the java or java-library plugin.

These reports offer a user-friendly interface to browse test results, making analysis straightforward.

Finding the Report File

After executing your tests using the test task, Gradle places the generated report in a specific directory. Look for build/reports/tests/test/index.html.

You can open this file directly in any web browser to view a comprehensive overview of your test run. To generate one, simply run: ./gradlew test

Exploring Report Details

The HTML report provides valuable details:

  • Summary: Total tests, failures, and skipped tests.
  • Test Classes: A list of all executed test classes.
  • Individual Tests: Status and duration for each test method.
  • Failure Details: Stack traces and error messages for failed tests.

This structure helps you drill down from a high-level overview to specific problem areas.

Running Specific Tests

Sometimes you don't need to run all tests. Perhaps you're debugging a specific feature or re-running a failed test.

Gradle allows you to filter which tests are executed, saving time and focusing your efforts. This is done using the --tests command-line option.

Filter by Class Name

To run all tests within a specific test class, provide its fully qualified name with the --tests flag.

For example, if you have a class named com.example.MyFeatureTest, you'd run:

./gradlew test --tests com.example.MyFeatureTest

This executes every test method inside that single class.

Execute a Single Method

You can get even more granular by specifying a particular test method within a class. Append the method name to the fully qualified class name.

If com.example.MyFeatureTest has a method testSpecificCase, use:

./gradlew test --tests com.example.MyFeatureTest.testSpecificCase

This is extremely useful for focused debugging.

Using Wildcards in Filters

Gradle's --tests option supports wildcards (*) for more flexible matching. This allows you to run groups of tests that follow a pattern.

  • *IntegrationTest: Runs all classes ending with "IntegrationTest".
  • com.example.*: Runs all tests in the com.example package and its subpackages.
  • *.testFailure*: Runs any method named `testFailure` (or similar) in any class.

Multiple Filter Patterns

You can apply multiple --tests options in a single command. Gradle will run any test that matches at least one of the provided patterns.

For example, to run tests from two different classes:

./gradlew test --tests com.example.ClassA --tests com.example.ClassB

This provides powerful control over your test execution.

Quick Check: Filtering

Consider a project with a test class com.myapp.services.UserServiceTest containing methods testCreateUser and testDeleteUser.

Which Gradle command will run only the testCreateUser method?

Recap: Reports & Filtering

In this lesson, we explored the critical role of test reports in Gradle. You learned that:

  • Gradle automatically generates detailed HTML test reports.
  • These reports are found in build/reports/tests/test/index.html.
  • You can filter test execution using the --tests option.
  • Filters can target classes, methods, or use wildcards for flexibility.

Mastering these techniques helps you efficiently manage and debug your test suite!

Często zadawane pytania

Czy lekcja „Raporty z testów i filtrowanie” jest bezpłatna?

Tak — pełny tekst „Raporty z testów i filtrowanie” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Groovy & Gradle: JVM Automation and Build Engineering, przejdź na CoddyKit PRO. Kurs Groovy & Gradle: JVM Automation and Build Engineering zawiera 4 lekcji w sumie.

Co nauczysz się w „Raporty z testów i filtrowanie”?

Generuj i analizuj raporty z testów oraz naucz się filtrować testy w celu ukierunkowanego uruchamiania. Ćwiczysz Groovy & Gradle: JVM Automation and Build Engineering z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Groovy & Gradle: JVM Automation and Build Engineering?

Nie wymagamy żadnego doświadczenia. Groovy & Gradle: JVM Automation and Build Engineering w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 2 z 4.

Ile czasu zajmuje lekcja „Raporty z testów i filtrowanie”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Groovy & Gradle: JVM Automation and Build Engineering?

Tak. Każda lekcja Groovy & Gradle: JVM Automation and Build Engineering zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Testy jednostkowe i integracyjne
  2. Raporty z testów i filtrowanie
  3. Pokrycie kodu i analiza statyczna
  4. Fixtures testowe i współdzielony kod testów
← Powrót do Groovy & Gradle: JVM Automation and Build Engineering