0Pricing
Groovy & Gradle: JVM Automation and Build Engineering · Leçon

Rapports et filtrage des tests

Générez et analysez des rapports de test, puis apprenez à filtrer les tests pour cibler leur exécution.

Rapports et filtrage des tests est une leçon Groovy & Gradle: JVM Automation and Build Engineering gratuite sur CoddyKit. Ceci est la leçon 2 sur 4. Tu peux lire la leçon complète ci-dessous gratuitement — puis la pratiquer en direct dans le navigateur avec un éditeur de code intégré et un tuteur IA 24/7. Elle fait partie du parcours d'apprentissage Groovy & Gradle: JVM Automation and Build Engineering, et ta progression se synchronise sur le web et l'application CoddyKit. Le cours Groovy & Gradle: JVM Automation and Build Engineering comprend 4 leçons au total.

Certaines parties de cette leçon n'ont pas encore été traduites et s'affichent en anglais.

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!

Questions Fréquemment Posées

La leçon « Rapports et filtrage des tests » est-elle gratuite ?

Oui — le texte complet de « Rapports et filtrage des tests » est gratuit à lire ici sur le web. Pour la pratiquer de manière interactive (un éditeur de code intégré et un tuteur IA 24/7) et déverrouiller le reste du cours Groovy & Gradle: JVM Automation and Build Engineering, passe à CoddyKit PRO. Le cours Groovy & Gradle: JVM Automation and Build Engineering comprend 4 leçons au total.

Qu'est-ce que j'apprendrai dans « Rapports et filtrage des tests » ?

Générez et analysez des rapports de test, puis apprenez à filtrer les tests pour cibler leur exécution. Tu pratiques Groovy & Gradle: JVM Automation and Build Engineering avec du code pratique que tu exécutes directement dans le navigateur, et un tuteur IA 24/7 répond à tes questions au fur et à mesure que tu avances dans la leçon.

Dois-je avoir de l'expérience pour commencer Groovy & Gradle: JVM Automation and Build Engineering ?

Aucune expérience préalable n'est requise. Groovy & Gradle: JVM Automation and Build Engineering sur CoddyKit est structuré pour les débutants jusqu'aux apprenants avancés, donc tu peux commencer ici ou depuis le début et avancer à ton rythme. Ceci est la leçon 2 sur 4.

Combien de temps prend la leçon « Rapports et filtrage des tests » ?

La plupart des leçons CoddyKit prennent environ 5–10 minutes. Chacune est courte et interactive, tu progresses régulièrement et tu repiques exactement où tu t'es arrêté sur le web et l'app.

Peux-tu écrire et exécuter du code dans cette leçon Groovy & Gradle: JVM Automation and Build Engineering ?

Oui. Chaque leçon Groovy & Gradle: JVM Automation and Build Engineering inclut un éditeur de code intégré, tu écris et exécutes du vrai code directement dans ton navigateur et tu reçois des retours IA instantanés — aucune configuration locale requise.

Toutes les leçons de ce cours

  1. Tests unitaires et d’intégration
  2. Rapports et filtrage des tests
  3. Couverture du code et analyse statique
  4. Dispositifs de test et code de test partagé
← Retour à Groovy & Gradle: JVM Automation and Build Engineering