Skip to content

Conversation

qinfendeheichi
Copy link

@qinfendeheichi qinfendeheichi commented Jul 15, 2025

Make test method specification optional in Ant-based test execution

Run CI tests

Problem

As discussed in #480 (comment), the current implementation of Defects4j does not support running a specific test class without specifying a test case method. The possible workaround may not be easily integrated with the overall infrastructure.

Solution

This patch introduces two conditional properties in defects4j.build.xml file:

<condition property="run.test.with.method">
    <and>
        <isset property="test.entry.class"/>
        <isset property="test.entry.method"/>
    </and>
</condition>

<condition property="run.test.without.method">
    <and>
        <isset property="test.entry.class"/>
        <not>
            <isset property="test.entry.method"/>
        </not>
    </and>
</condition>

Then, it defines two elements conditionally:

<!-- Case 1: class and method specified -->
<test name="${test.entry.class}" methods="${test.entry.method}" if="run.test.with.method" />

<!-- Case 2: only class specified -->
<test name="${test.entry.class}" if="run.test.without.method" />

Correspondingly, the command check is updated in run_tests subroutine in Project.pm file

The enhancement supports both testClass::testMethod and testClass style test execution.

Example Usage

Defects4j coverage -t org.example.MyTest org.apache.commons.math3.analysis.integration.gauss.HermiteParametricTest

Update defects4j.build.xml file
support usage such as "Defects4j coverage -t TestClass
@qinfendeheichi qinfendeheichi marked this pull request as draft July 17, 2025 06:31
@qinfendeheichi qinfendeheichi marked this pull request as ready for review July 17, 2025 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant