Closed aburasali closed 3 years ago
Hi @aburasali,
I want to disable some features that EvoSuite uses, such as disabling using archive test cases and/or disabling Mocking objects.
Assuming you're using the command line version, you can disable, e.g., archive by adding the following -Dtest_archive=false
to your command. Check out all EvoSuite's properties in here.
Assuming you're using the maven plugin, you can disable, e.g., archive by adding the following -DextraArgs="-Dtest_archive=false"
to your command.
I believe if I use mvn evosuite: clean, I'll make EvoSuite clean and delete all the previous files/test cases that have been generated but I'm not sure about it.
Yes, mvn evosuite:clean
does remove all local files created by EvoSuite.
-- Best, Jose
Thank you!
Hi, I just figured out that -DextraArgs="-Dmock_if_no_generator=false" did not work, and EvoSuite still generates mock objects for classes.
Hi @aburasali,
I fail to see how -DextraArgs="-Dmock_if_no_generator=false"
does not work. As far I can see, mock objects are created if and only if these conditions or these conditions are satisfied.
For the former set of conditions
if (canUseFunctionalMocks &&
TimeController.getInstance().getPhasePercentage() >= Properties.FUNCTIONAL_MOCKING_PERCENT &&
Randomness.nextDouble() < Properties.P_FUNCTIONAL_MOCKING &&
FunctionalMockStatement.canBeFunctionalMocked(type)) {
even if canUseFunctionalMocks
, TimeController.getInstance().getPhasePercentage() >= Properties.FUNCTIONAL_MOCKING_PERCENT
, and FunctionalMockStatement.canBeFunctionalMocked(type)
are enable or return true, by default Randomness.nextDouble() < Properties.P_FUNCTIONAL_MOCKING
is evaluated as false. Randomness.nextDouble()
returns a number between 0.0 and 1.0 and Properties.P_FUNCTIONAL_MOCKING
is 0 by default.
For the latter set of conditions
if (canUseFunctionalMocks && (Properties.MOCK_IF_NO_GENERATOR || Properties.P_FUNCTIONAL_MOCKING > 0)) {
canUseFunctionalMocks
might be true, Properties.MOCK_IF_NO_GENERATOR
is true by default but when you set -DextraArgs="-Dmock_if_no_generator=false"
this property is disabled, and Properties.P_FUNCTIONAL_MOCKING
is not (by default) greater than 0. Thus, even if canUseFunctionalMocks
is true, the second part of the if is false.
Nevertheless and assuming -DextraArgs="-Dmock_if_no_generator=false"
did not work for you, the following might work:
mvn evosuite:generate -Dcuts="__class_under_test__"
-DextraArgs="-Dmock_if_no_generator=false -Dp_functional_mocking=0 -Dfunctional_mocking_input_limit=0 -Dfunctional_mocking_percent=0"
By the way, are using the latest version of EvoSuite (i.e., 1.0.7-SNAPSHOT) or version 1.0.6?
-- Best, Jose
Hello Jose, I appreciate your patience and for answering my questions. I use EvoSuite 1.0.6. I might be missing something here but I used the command that you provided but no luck unless I'm missing something and did not understand the test case that EvoSuite generated.
Here is the command that I ran: mvn evosuite:generate -DtimeInMinutesPerClass=2 evosuite:export -DextraArgs="-Dmock_if_no_generator=false -Dp_functional_mocking=0 -Dfunctional_mocking_input_limit=0 -Dfunctional_mocking_percent=0" Here is a test case that was generated by EvoSuite @Test(timeout = 4000) public void test1() throws Throwable { Locale locale0 = Locale.PRC; MockGregorianCalendar mockGregorianCalendar0 = new MockGregorianCalendar(locale0); Foo.fromCalendarFields(mockGregorianCalendar0); assertEquals(1, mockGregorianCalendar0.getMinimalDaysInFirstWeek()); } As you can see EvoSuite generated a mock object for the Calendar. Am I right?
Any help/explanation would be appreciated!
EvoSuite tries to replace nondeterministic JVM calls (e.g. System.getCurrentTimeMillis()) with deterministic Function calls. I think the flag -Dreplace_calls=false will prevent the usage of MockGregorianCalendar.
Note: with this feature disabled, some test cases may be nondeterministic.
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 disable some features that EvoSuite uses, such as disabling using archive test cases and/or disabling Mocking objects. I believe if I use mvn evosuite: clean, I'll make EvoSuite clean and delete all the previous files/test cases that have been generated but I'm not sure about it.
Steps to Reproduce
Please break down here below all the needed steps to reproduce the issue. [If possible, please upload an example of the project you are generating tests for.]
1. 2. 3.
EvoSuite Arguments
Please provide the whole EvoSuite commmand you executed (if relevant)
Current Result
Please describe here below the current result you got (if relevant) [if relevant, include a screenshot]
Expected result
Please describe here below what should be the expected behaviour (if relevant)
Additional info
Please add any information of interest here below