sunjun-group / Ziyuan

1 stars 5 forks source link

Fail to Generate Some Test Case #156

Open llmhyy opened 6 years ago

llmhyy commented 6 years ago

Hi Lyly,

org.apache.commons.math.analysis.interpolation.BicubicSplineInterpolatingFunction.searchIndex.286 org.apache.commons.math.analysis.interpolation.MicrosphereInterpolatingFunction.value.190

java.util.NoSuchElementException
    at java.util.HashMap$HashIterator.nextNode(HashMap.java:1439)
    at java.util.HashMap$ValueIterator.next(HashMap.java:1466)
    at learntest.activelearning.core.testgeneration.localsearch.GradientBasedSearch.doSearch(GradientBasedSearch.java:210)
    at learntest.activelearning.core.testgeneration.localsearch.GradientBasedSearch.doDoubleSearch(GradientBasedSearch.java:286)
    at learntest.activelearning.core.testgeneration.localsearch.GradientBasedSearch.generateInputByGradientSearch(GradientBasedSearch.java:97)
    at learntest.activelearning.core.testgeneration.SearchBasedTestGenerator.traverseLearning(SearchBasedTestGenerator.java:67)
    at learntest.activelearning.core.testgeneration.SearchBasedTestGenerator.traverseLearning(SearchBasedTestGenerator.java:74)
    at learntest.activelearning.core.testgeneration.SearchBasedTestGenerator.cover(SearchBasedTestGenerator.java:39)
    at learntest.activelearning.core.SearchBasedLearnTest.generateTestcase(SearchBasedLearnTest.java:69)
    at learntest.activelearning.plugin.handler.HillClimbingSearchTestHandler.execute(HillClimbingSearchTestHandler.java:51)
    at learntest.activelearning.plugin.handler.HillClimbingSearchTestHandler$1.run(HillClimbingSearchTestHandler.java:29)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
lylytran commented 6 years ago

For these kind of classes, usually we cannot generate a good initialization statement. Because of the improper random input, its execution takes very long time. So in such case, we discard it due to timeout, and the object is assigned null. But in case of the target method receiver like this, it might not be a good idea because there will be no valid testcase is generated. The random value selected in GentestRandomness will affect this most.

lylytran commented 5 years ago

Hi Lin Yun, there is a case in which reference value isNull is false but generated test still assign value for the object as null because gentest cannot generate constructor call for target method receiver sucessfully. for this method, the constructor MicrosphereInterpolatingFunction(double[][] xval, double[] yval, int brightnessExponent, int microsphereElements, UnitSphereRandomVectorGenerator rand) might not init sucessfully because of the initialization of UnitSphereRandomVectorGenerator rand might take long time. The timeout for the execution of extension method: VariableRuntimeExecutor.extMethodExecTimeout=20ms timeout for the execution of target method: VariableRuntimeExecutor.methodExecTimeout=200ms for example: org.apache.commons.math.analysis.interpolation.MicrosphereInterpolatingFunction.value.190: UnitSphereRandomVectorGenerator rand = new UnitSphereRandomVectorGenerator(); rand.setRand() => 20ms MicrosphereInterpolatingFunction a = new MicrosphereInterpolatingFunction(); a.setValue() => 20ms a.value() => 200ms

Just in case you might want to adjust the value.