Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Randoop generates uncompilable sequences because "reference to assertEquals is ambiguous" #1261

Open
varuniy opened this issue Nov 21, 2023 · 0 comments

Comments

@varuniy
Copy link
Collaborator

varuniy commented Nov 21, 2023

Randoop Version: 4.3.2
Output of java -version:

openjdk version "17.0.5" 2022-10-18
OpenJDK Runtime Environment Temurin-17.0.5+8 (build 17.0.5+8)
OpenJDK 64-Bit Server VM Temurin-17.0.5+8 (build 17.0.5+8, mixed mode, sharing)

Operating System Version:

Edition: Windows 10 Home
Version: 22H2
Installed on: 5/‎3/‎2021
OS build: 19045.3693
Serial number: 004802701057
Experience: Windows Feature Experience Pack 1000.19053.1000.0

Steps I took:

  1. Create a directory called test anywhere
  2. Inside this directory, create three files called MyClass1.java and MyClass2.java and myclasses.txt
  3. Paste the following contents into MyClass1.java, MyClass2.java, and myclasses.txt respectively:
import java.util.*;

public class MyClass1 {

    public Object input;

    public MyClass1 (Object input) {
        this.input = input;
    }

    public String privateMethod1 (Object input) {
        return input.toString();
    }
} 
import java.util.*;

public class MyClass2 {

    public Integer input;

    public MyClass2 (Integer input) {
        this.input = input;
    }

    public Integer privateMethod2(Integer input) {
        return input * 2;
    }
}
MyClass1
MyClass2
  1. Compile MyClass1.java and MyClass2.java using javac MyClass1 and javac MyClass2
  2. Change into the directory containing the test subdirectory and run the following command:
    java -classpath "test/;[path to randoop-all-4.3.2.jar]" randoop.main.Main gentests --classlist="test/myclasses.txt" --time-limit=4

Note: If trying to replicate this error on Linux, you may need to edit some of the above commands. Notably, please change the ";" to ":"

This was the output I generated:

Randoop for Java version 4.3.2.
Will try to generate tests for 2 classes.
PUBLIC MEMBERS=10
Explorer = ForwardGenerator(steps: 0, null steps: 0, num_sequences_generated: 0;                                             
    allSequences: 0, regresson seqs: 0, error seqs: 0=0=0, invalid seqs: 0, subsumed_sequences: 0, num_failed_output_test: 0;
    sideEffectFreeMethods: 1113, runtimePrimitivesSeen: 38)                                                                  

Progress update: steps=1, test inputs generated=0, failing inputs=0      (2023-11-21T21:14:01.334531100Z     8.14M used)
Progress update: steps=75, test inputs generated=58, failing inputs=0      (2023-11-21T21:14:05.340745Z     89.1M used)
Normal method executions: 4690
Exceptional method executions: 0
Created file C:\Users\varun\IdeaProjects\randoop\RegressionTest0.java
Created file C:\Users\varun\IdeaProjects\randoop\RegressionTest.java
Wrote regression JUnit tests.
About to look for flaky methods.

Invalid tests generated: 0

Uncompilable sequences generated (count: 24).
Please report uncompilable sequences at https://github.com/randoop/randoop/issues ,
providing the information requested at https://randoop.github.io/randoop/manual/index.html#bug-reporting .

Obviously, I don't think Randoop should be generating uncompilable sequences here. Additionally, I was able to print out why some of the sequences being generated were uncompilable and this was the output for one of those sequences:

isCompilable => false
RandoopTemporarySeqTest16.java:19: error: reference to assertEquals is ambiguous
        org.junit.Assert.assertEquals("'" + int3 + "' != '" + 20 + "'", int3, 20);
                        ^
  both method assertEquals(java.lang.String,java.lang.Object,java.lang.Object) in org.junit.Assert and method assertEquals(java.lang.String,long,long) in org.junit.Assert match
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class RandoopTemporarySeqTest16 {

    public static boolean debug = false;

    @Test
    public void theSequence16() throws Throwable {
        if (debug)
            System.out.format("%n%s%n", "RandoopTemporarySeqTest16.theSequence16");
        MyClass2 myClass2_1 = new MyClass2((java.lang.Integer) 1);
        java.lang.Integer int3 = myClass2_1.privateMethod2((java.lang.Integer) 10);
        java.lang.Integer int5 = myClass2_1.privateMethod2((java.lang.Integer) 20);
        java.lang.Integer int7 = myClass2_1.privateMethod2((java.lang.Integer) (-1));
        java.lang.Integer int9 = myClass2_1.privateMethod2((java.lang.Integer) 100);
        org.junit.Assert.assertEquals("'" + int3 + "' != '" + 20 + "'", int3, 20);
        org.junit.Assert.assertEquals("'" + int5 + "' != '" + 40 + "'", int5, 40);
        org.junit.Assert.assertEquals("'" + int7 + "' != '" + (-2) + "'", int7, (-2));
        org.junit.Assert.assertEquals("'" + int9 + "' != '" + 200 + "'", int9, 200);
    }
}

Thanks!

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

No branches or pull requests

1 participant