llmhyy / microbat

A feedback-based debugger for interactively recommending suspicious step in buggy program execution.
54 stars 15 forks source link

"No runnable methods" error #237

Closed bchenghi closed 2 years ago

bchenghi commented 2 years ago

"No runnable methods" failure is returned when running microbat with the option "is to run JUnit test?" turned on.

Launch class: test.MainTest Test method: test

It was done with a simple Maven project. The structure is as follows.

image

The pom.xml and test class is provided below.

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>Test</groupId>
    <artifactId>Test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    <build>
        <testSourceDirectory>src/test</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M6</version>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.eclipse.jdt</groupId>
            <artifactId>org.eclipse.jdt.core</artifactId>
            <version>3.29.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.osgi.service</groupId>
                    <artifactId>org.osgi.service.prefs</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
          <groupId>com.beust</groupId>
          <artifactId>jcommander</artifactId>
          <version>1.82</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20220320</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>RELEASE</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>RELEASE</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

</project>

The test class:

package test;
import org.junit.jupiter.api.Test;

class MainTest {
    @Test
    void test() {
        System.out.println("testing");
    }
}
bchenghi commented 2 years ago

This error was resolved after JUnit4 was used. (import org.junit.Test instead). The test class also has to be public.