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

Using EvoSuite target_method #439

Open
imesecan opened this issue Nov 18, 2022 · 0 comments
Open

Using EvoSuite target_method #439

imesecan opened this issue Nov 18, 2022 · 0 comments

Comments

@imesecan
Copy link

Context

I want to use EvoSuite to generate unit test for classes some of which have 10,000 methods. I know this is not realistic, but this is a test set to show some extremities. Luckily EvoSuite has target_method option which can help in such cases.

Steps to Reproduce

I see one example that talks about this option, but I couldn't find enough resources that can direct me to the proper use.
For example I use the following class

import java.util.*;
class EvoDriver{
    public static int start(int num) {
        boolean h = num > 0;        
        if (deep1(h)) 
            return 1;
        return 0;
    }
    public static boolean deep1(boolean x) {
        return deep2(x);
    }
    public static boolean deep2(boolean x) {
        return deep3(x);
    }
    public static boolean deep3(boolean x) {
        return deep4(x);
    }
    public static boolean deep4(boolean x) {
        return deep5(x);
    }
    public static boolean deep5(boolean x) {
      return x;
    }
    public static void main (String [] args) 
    {
        Scanner inp = new Scanner(System.in); 
        System.out.println(start(inp.nextInt()));
    }
}

EvoSuite Arguments

Inferring from this example, when I compile and run this for the start function, it works and generates a test set:
also works when I use target_method

java -Xmx1G  -Xss1G  -jar evosuite-1.2.0.jar  -projectCP ./  -class EvoDriver  -seed 110   -Dsearch\_budget=60  -Dstopping\_condition=MaxTime  -Dtarget\_method=start(I)I 

But I don't know how to make this work for other types of input parameters (or set of input parameters).

Current Result

For example, once it failed for deep1 function and in the report it used deep1(z)z. But when I try this (or deep1(b)b), it fails.

* EvoSuite 1.2.0
* Going to generate test cases for class: EvoDriver
* Starting Client-0
* Connecting to master process on port 14647
* Analyzing classpath: 
  - ./
* Finished analyzing classpath
* Generating tests for class EvoDriver
* Test criteria:
  - Line Coverage
  - Branch Coverage
  - Exception
  - Mutation testing (weak)
  - Method-Output Coverage
  - Top-Level Method Coverage
  - No-Exception Top-Level Method Coverage
  - Context Branch Coverage
* Total number of test goals for DYNAMOSA: 22
* Using seed 124
* Starting evolution
[Progress:>                             0%] [Cov:>                                  0%]* Computation finished
[MASTER] 15:45:35.276 [logback-2] ERROR ClientNodeImpl - Error when generating tests for: EvoDriver with seed 124. Configuration id : null
java.lang.NullPointerException: null
	at org.evosuite.ga.metaheuristics.mosa.structural.MultiCriteriaManager.addDependencies4WeakMutation(MultiCriteriaManager.java:298)
	at org.evosuite.ga.metaheuristics.mosa.structural.MultiCriteriaManager.<init>(MultiCriteriaManager.java:121)
	at org.evosuite.ga.metaheuristics.mosa.DynaMOSA.generateSolution(DynaMOSA.java:146)
	at org.evosuite.ga.metaheuristics.TestSuiteAdapter.generateSolution(TestSuiteAdapter.java:136)
	at org.evosuite.strategy.MOSuiteStrategy.generateTests(MOSuiteStrategy.java:122)
	at org.evosuite.TestSuiteGenerator.generateTests(TestSuiteGenerator.java:630)

Expected result

Can you please provide more information on the use of this option?

@imesecan imesecan changed the title Using EvoSuite target\_method Using EvoSuite target_method Nov 18, 2022
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