Open egorklimov opened 1 year ago
I also tried this solution with java19 and it hangs without any log. I'll try to debug it
I tried it on this simple app:
package org.example;
public class Main {
public boolean is2(int target) {
return target == 2;
}
public static void main(String[] args) {
System.out.println(new Main().is2(2));
System.out.println(new Main().checkObject(new Circle(1)));
}
record Human(String name, int age, String profession) {}
record Circle(int radius) {}
public String checkObject(Object obj) {
if (obj instanceof Human h) {
return "Name: %s, age: %s and profession: %s".formatted(h.name(), h.age(), h.profession());
} else if (obj instanceof Circle c) {
return "This is a circle %d".formatted(c.radius);
}
return "It is an object";
}
}
And got the following tests:
/*
* This file was automatically generated by EvoSuite
* Thu Jun 01 10:40:06 GMT 2023
*/
package org.example;
import org.junit.Test;
import static org.junit.Assert.*;
import org.example.Main;
import org.junit.runner.RunWith;
import shaded.org.evosuite.runtime.EvoRunner;
import shaded.org.evosuite.runtime.EvoRunnerParameters;
@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = true)
public class Main_ESTest extends Main_ESTest_scaffolding {
@Test(timeout = 4000)
public void test0() throws Throwable {
Main main0 = new Main();
Object object0 = new Object();
String string0 = main0.checkObject(object0);
assertEquals("It is an object", string0);
}
@Test(timeout = 4000)
public void test1() throws Throwable {
Main main0 = new Main();
boolean boolean0 = main0.is2(3);
assertFalse(boolean0);
}
@Test(timeout = 4000)
public void test2() throws Throwable {
Main.Human main_Human0 = new Main.Human("", 0, "");
assertEquals("Human[name=, age=0, profession=]", main_Human0.toString());
}
@Test(timeout = 4000)
public void test3() throws Throwable {
Main main0 = new Main();
Main.Human main_Human0 = new Main.Human("", 0, "");
String string0 = main0.checkObject(main_Human0);
assertEquals("Name: , age: 0 and profession: ", string0);
}
}
Could you restart tests? I tried them locally and it is green, maybe it is a flaky test
Solution with add-opens
is not working in ubuntu openjdk 17
Solution with add-opens
is not working in ubuntu openjdk 17
Hello!
I tried to run evosuite with Java 17. But it failed due to java modules error:
module java.base does not "opens java.util" to unnamed module
.I added a library that supports opening models in runtime and updated xstream and asm versions. I also tried to add
add-opens
to jar manifest, but that didn't help. This solution is maybe not so good because it opens all modules, maybe we should choose a set of modules and only open them.It now at least works on java 17, but maybe we need to update the instrumentation too. I'm not familiar with the evosuite instrumentation, but if I can help support java 17 please let me know what I should do ;)