Skip to content

How to execute custom test cases or specified test cases rather than all tests on gitbug-java? #46

Open

Description

@cc32

I am going to evaluate my own fault localization approach on GitBug-Java. To do this, I need to do the following steps:

  1. Inject extra test cases into the test suite.
  2. Compile the project.
  3. Execute the tests.

I tried like this:

  1. I checked out one of the bugs and modified one of the .java Files of the Test Classes. It looks like this:
public class Gt06ProtocolDecoderTest extends ProtocolTest {

    @Test
    public void tryTestInjection() throws Exception {
        int a=1;
        int b=0;
        assertEquals(a,b);     // This is the custom test case, and it always fails.
    }

    @Test
    public void testDecode() throws Exception {
      ...   // This is the original Failed Test Case
    }
}
  1. I execute gitbug-java run checkout --act-cache=act-cache and get:
Expected executed tests: 479
Executed tests: 480
Passing tests: 478
Skipped tests: 23
Failing tests: 2
Failed tests:
- org.traccar.protocol.Gt06ProtocolDecoderTest#tryTestInjectsion()
- org.traccar.protocol.Gt06ProtocolDecoderTest#testDecode()

It turns out that my custom test case is compiled and executed. But to speed up, is it possible to execute single test case rather than all tests?
How can I do?

Activity

  1. cc32 commented on Aug 21, 2025

    @cc32
    Author

    I have tried to set the parameter keep_containers=True when I execute the gitbug-java run checkout --act-cache=act-cache, so that I can get the container in which the required dependencies are packaged (I guess). But when I entered the container, I failed to build the project, like this:

    runner@9ab2a1ad3e05:/.../.../gitbug-java/traccar$ gradle build
    
    FAILURE: Build failed with an exception.
    
    * Where:
    Build file '/.../.../gitbug-java/traccar/build.gradle' line: 4
    
    * What went wrong:
    Plugin [id: 'com.google.protobuf', version: '0.9.3'] was not found in any of the following sources:
    
    - Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
    - Plugin Repositories (could not resolve plugin artifact 'com.google.protobuf:com.google.protobuf.gradle.plugin:0.9.3')
      Searched in the following repositories:
        Gradle Central Plugin Repository
    
    * Try:
    > Run with --stacktrace option to get the stack trace.
    > Run with --info or --debug option to get more log output.
    > Run with --scan to get full insights.
    > Get more help at https://help.gradle.org.
    
    BUILD FAILED in 569ms
    
    
  2. Nfsaavedra commented on Aug 21, 2025

    @Nfsaavedra
    Contributor
    1. For that, you might want to modify the GitHub Actions workflows in the checked out repository so that only the tests that you want to run are executed. For instance, for traccar-traccar-95fdfd770130 you have a single workflow defined in the folder .github/workflows. If you change the ./gradlew build there to something such as ./gradlew test --no-daemon --warning-mode=fail --tests 'Gt06ProtocolDecoderTest' and then you run it with gitbug-java run, only those tests will be executed. We call this instrumentation in gitbugactions. You can take a look on how it's done there to generalize it for other samples (we don't filter the tests but we do similar things).

    2. For that sample you should use ./gradlew instead of gradle as it is defined in the workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions