تقارير الاختبارات وتصفيتها
أنشئ تقارير الاختبارات وحلّلها، وتعلّم تصفية الاختبارات لتنفيذ مستهدف
تقارير الاختبارات وتصفيتها درس مجاني في Groovy & Gradle: JVM Automation and Build Engineering على CoddyKit. هذا هو الدرس 2 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Groovy & Gradle: JVM Automation and Build Engineering، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Groovy & Gradle: JVM Automation and Build Engineering 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
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.MyFeatureTestThis 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.testSpecificCaseThis 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 thecom.examplepackage 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.ClassBThis 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
--testsoption. - Filters can target classes, methods, or use wildcards for flexibility.
Mastering these techniques helps you efficiently manage and debug your test suite!
الأسئلة الشائعة
هل درس «تقارير الاختبارات وتصفيتها» مجاني؟
نعم — نص درس «تقارير الاختبارات وتصفيتها» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Groovy & Gradle: JVM Automation and Build Engineering، انتقل إلى CoddyKit PRO. تتضمن دورة Groovy & Gradle: JVM Automation and Build Engineering 4 دروس في المجموع.
ماذا ستتعلم في «تقارير الاختبارات وتصفيتها»؟
أنشئ تقارير الاختبارات وحلّلها، وتعلّم تصفية الاختبارات لتنفيذ مستهدف تتمرن على Groovy & Gradle: JVM Automation and Build Engineering مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Groovy & Gradle: JVM Automation and Build Engineering؟
لا تُشترط خبرة سابقة. Groovy & Gradle: JVM Automation and Build Engineering على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 2 من أصل 4.
كم من الوقت يستغرق درس «تقارير الاختبارات وتصفيتها»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Groovy & Gradle: JVM Automation and Build Engineering هذا؟
نعم. كل درس في Groovy & Gradle: JVM Automation and Build Engineering يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- اختبارات الوحدات والتكامل
- تقارير الاختبارات وتصفيتها
- تغطية التعليمات البرمجية والتحليل الساكن
- تجهيزات الاختبار وشيفرة الاختبار المشتركة