EvoSuite / evosuite

EvoSuite - automated generation of JUnit test suites for Java classes
http://www.evosuite.org
GNU Lesser General Public License v3.0
823 stars 341 forks source link

feature-request in Evosuite #443

Open Vishalsng112 opened 1 year ago

Vishalsng112 commented 1 year ago

Context

Please provide below a detailed introduction to the issue itself, and describe what you were doing when the issue happened. Or, what do you want to achieve?

I want to generate a testsuite with some constrained, like some specific lines that must not be executed in the generated test suite. For example, for the given program below, I want Evosuite to generate the testsuite such that it will not execute the function public T pop(). Is there any parameter already in the tool where I can specify line numbers to execute or not execute? If not, can you please tell me where I need to make changes in the source code so I can get this feature in the tool? It will be beneficial for my work.

public class Stack<T> {
    private int capacity = 10;
    private int pointer  = 0;
    private T[] objects = (T[]) new Object[capacity];

    public void push(T o) {
    if(pointer >= capacity)
        throw new RuntimeException("Stack exceeded capacity!");
    objects[pointer++] = o;
    }
    public T pop() {
    if(pointer <= 0)
        throw new EmptyStackException();
    return objects[--pointer];
    }
    public boolean isEmpty() {
    return pointer <= 0;
    } 
}
firhard commented 11 months ago

You can use one of these parameters to set which methods you'd like to generate tests for:

https://github.com/EvoSuite/evosuite/blob/HEAD/client/src/main/java/org/evosuite/Properties.java#L1594-L1610