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

Smell free tests #459

Open
wants to merge 160 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
49723bb
Test smells as secondary criterion V1
fc51111 Nov 24, 2021
61a7904
Test smells secondary criterion structure
fc51111 Nov 27, 2021
bc7b95d
Added Indirect Testing smell
fc51111 Nov 28, 2021
c463940
Added ObscureInlineSetup smell
fc51111 Nov 29, 2021
92ee33e
Added EmptyTest smell
fc51111 Dec 5, 2021
62bd4c5
Added SlowTests smell
fc51111 Dec 5, 2021
65544fb
DummySystemTest
fc51111 Dec 14, 2021
b108890
AssertionRoulette and UnknownTest
fc51111 Dec 21, 2021
ff0f809
BrittleAssertion and UnusedInputs
fc51111 Dec 21, 2021
6efd28e
DuplicateAssert and RedundantAssertion
fc51111 Dec 21, 2021
7419c7f
Update to include test suites
fc51111 Jan 10, 2022
16ce6c9
EagerTest and IndirectTesting fix
fc51111 Jan 10, 2022
7ae1011
Lack of Cohesion of Methods
fc51111 Jan 10, 2022
7a138a6
Count test suite smells in abstract
fc51111 Jan 11, 2022
47bba20
MysteryGuest and LazyTest
fc51111 Jan 12, 2022
b8d3254
SensitiveEquality
fc51111 Jan 13, 2022
d3b3a8e
LikelyIneffectiveObjectComparison
fc51111 Jan 14, 2022
5dcaa72
Write test smell info to statistics file
fc51111 Jan 15, 2022
9e0fbec
Set smell name inside respective constructor
fc51111 Jan 18, 2022
a65fb39
Experimental unit test for test smells
fc51111 Jan 19, 2022
86d8009
Requested changes
fc51111 Jan 21, 2022
2237b86
Change test smell names
fc51111 Jan 25, 2022
70367b0
Test Smell Timeline Variables
fc51111 Feb 14, 2022
8a6a8bf
The first completed unit test
fc51111 Feb 21, 2022
9fa2c81
Overreferencing & Resource Optimism
fc51111 Feb 22, 2022
c6aca39
Testing classes
fc51111 Feb 24, 2022
3fdd80e
Update EagerTest and respective unit test
fc51111 Feb 24, 2022
c80838e
Indirect Testing correction
fc51111 Feb 24, 2022
6061077
Chromosomes manage the respective smell metrics
fc51111 Feb 24, 2022
7eb2500
TestCodeDuplication & RottenGreenTests
fc51111 Feb 26, 2022
eebc9db
Update runtime variables
fc51111 Feb 27, 2022
c3058a9
TestRedundancy incorrect version
fc51111 Feb 28, 2022
60e5a4c
General Updates
fc51111 Feb 28, 2022
ccca201
BrittleAssertion & RedundantAssertion update
fc51111 Mar 2, 2022
7466dd5
DuplicateAssert update
fc51111 Mar 2, 2022
d3c4e23
Two simple unit tests
fc51111 Mar 2, 2022
3b362eb
SlowTests update
fc51111 Mar 2, 2022
d515b79
Overreferencing & IndirectTesting update
fc51111 Mar 3, 2022
fe4c164
New changes
fc51111 Mar 3, 2022
3aa1b21
Do not compare equal chromosomes
fc51111 Mar 3, 2022
7b6bb7e
Merge branch 'master' into smell-free-tests
jose Mar 11, 2022
1063c45
Smells are not optimized by default, at least not for now.
jose Mar 15, 2022
086a339
TestRedundancy fixed
fc51111 Mar 17, 2022
9677216
AssertionRoulette & BrittleAssertion unit tests
fc51111 Mar 19, 2022
200a086
EagerTest & RedundantAssertion update
fc51111 Mar 20, 2022
3bd781b
Unit tests update
fc51111 Mar 20, 2022
4f0fa46
IndirectTesting update
fc51111 Mar 20, 2022
c94702b
EmptyTest & IndirectTesting unit tests
fc51111 Mar 20, 2022
1a7fdef
LackOfCohesionOfMethods correction & unit test
fc51111 Mar 21, 2022
a80390b
lazyTest correction & unit test
fc51111 Mar 21, 2022
cf7b6d2
LikelyIneffectiveObjectComparison & MysteryGuest tests & correction
fc51111 Mar 21, 2022
e5af363
ObscureInlineSetup unit test
fc51111 Mar 21, 2022
6d52ffb
Overreferencing update and unit test
fc51111 Mar 22, 2022
50fcfcd
ResourceOptimism unit test
fc51111 Mar 22, 2022
4d60b4e
SensitiveEquality update and unit test
fc51111 Mar 22, 2022
c67f10f
UnknownTest and UnusedInputs update
fc51111 Mar 22, 2022
4cf0500
UnknownTest UnusedInputs VerboseTest unit tests
fc51111 Mar 22, 2022
e9412ef
TestRedundancy timeline variable
fc51111 Mar 23, 2022
de566fd
Duplicate Assert update
fc51111 Mar 25, 2022
41e52c7
Smell descriptions v1
fc51111 Mar 25, 2022
48520c3
TestRedundancy descriptions
fc51111 Mar 25, 2022
a6be277
Overreferencing changed variable name
fc51111 Mar 26, 2022
b5073e3
SlowTests and SensitiveEquality updated description V1
fc51111 Mar 26, 2022
e9fdd1f
UnusedInputs and BrittleAssertion updated description V1
fc51111 Mar 26, 2022
b842bd8
Normalize test smell results
fc51111 Mar 26, 2022
b2cce91
AssertionRoulette unit test update
fc51111 Mar 28, 2022
6527c69
Normalize test smell results corrections
fc51111 Mar 28, 2022
a03347c
Eager Test done
fc51111 Mar 29, 2022
1e1d3f9
IndirectTesting done EagerTest description change
fc51111 Mar 29, 2022
2c8e4c7
LackOfCohesionOfMethods update
fc51111 Mar 29, 2022
fdf53e7
LazyTest done
fc51111 Mar 30, 2022
e06031d
VerboseTest done
fc51111 Mar 30, 2022
781941e
Execute tests before smell optimization post-processing
fc51111 Mar 30, 2022
a212568
SlowTests unit test
fc51111 Mar 30, 2022
4429732
Overreferencing new version
fc51111 Mar 30, 2022
9157be5
Overreferencing correction and unit test
fc51111 Mar 30, 2022
a5eeff4
EmptyTest update
fc51111 Mar 30, 2022
f75ab8a
ObscureInlineSetup new version
fc51111 Mar 30, 2022
3a52338
BrittleAssertion description change
fc51111 Mar 31, 2022
d8739cc
Write test smells post-processing update
fc51111 Mar 31, 2022
79e2656
General changes before major update
fc51111 Mar 31, 2022
07ee99b
computeNumberOfTestSmells changed return type to long
fc51111 Mar 31, 2022
e103daa
Unit test update computeNumberOfTestSmells
fc51111 Apr 1, 2022
c63b7fa
Created AbstractNormalizedTestCaseSmell to ensure good design
fc51111 Apr 1, 2022
8fd03dc
EmptyTest update
fc51111 Apr 1, 2022
10b4e6b
AssertionRoulette update
fc51111 Apr 2, 2022
43cd82a
UnrelatedAssertions and respective unit test
fc51111 Apr 2, 2022
7ec3c0f
EagerTest and IndirectTesting description correction
fc51111 Apr 2, 2022
d6405de
LikelyIneffectiveObjectComparison update
fc51111 Apr 3, 2022
f2ed5b6
MysteryGuest new version
fc51111 Apr 3, 2022
be855f2
MysteryGuest description unit test update
fc51111 Apr 3, 2022
9beae9c
ResourceOptimism new version
fc51111 Apr 3, 2022
6ef63a5
UnknownTest description and unit test
fc51111 Apr 4, 2022
26c4aec
TestRedundancy description update
fc51111 Apr 4, 2022
74bf059
ResourceOptimism corrections
fc51111 Apr 4, 2022
d15addf
RedundantAssertion description and unit test
fc51111 Apr 4, 2022
91d1c71
RedundantAssertion correction
fc51111 Apr 4, 2022
092f0a7
DuplicateAssert correction
fc51111 Apr 4, 2022
643d89b
RottenGreenTests description
fc51111 Apr 4, 2022
3c146db
RottenGreenTests unit test
fc51111 Apr 4, 2022
e81b68c
ObscureInlineSetup not count methods of class under test
fc51111 Apr 5, 2022
4437582
ObscureInlineSetup update include more types
fc51111 Apr 5, 2022
1b9f509
ObscureInlineSetup update description & unit test
fc51111 Apr 5, 2022
5c3cc3d
TestSmellsTestingClass1 update
fc51111 Apr 5, 2022
ba248d0
Removed TestCodeDuplication from secondary criteria
fc51111 Apr 5, 2022
27e0418
EmptyTest update (return 11)
fc51111 Apr 5, 2022
c5db848
Current version of TestCodeDuplication
fc51111 Apr 5, 2022
6762927
General changes to descriptions
fc51111 Apr 5, 2022
f2cceae
RottenGreenTests fixed bug
fc51111 Apr 5, 2022
9342a4c
TestRedundancy new version
fc51111 Apr 15, 2022
8a04d5d
smellScore & smellValues in Chromosome
fc51111 Apr 15, 2022
121229a
Attempt to simplify TestRedundancy.
jose Apr 16, 2022
665584e
Added TODO.
jose Apr 16, 2022
88ec703
EmptyTest new version
fc51111 Apr 17, 2022
8b710a1
Invalid smells return NaN
fc51111 Apr 18, 2022
525bc5a
Timeline variables correction - RMI
fc51111 Apr 22, 2022
540b1c0
Overreferencing correction
fc51111 Apr 23, 2022
23cf1f8
RottenGreenTests & RMI changes last execution
fc51111 Apr 24, 2022
df62066
IndirectTesting new version
fc51111 Apr 24, 2022
0f98f19
EagerTest update
fc51111 Apr 25, 2022
24693a7
ObscureInlineSetup update
fc51111 Apr 25, 2022
bb5aa72
Properties secondary objective correction
fc51111 Apr 26, 2022
8a82e63
AssertionRoulette small update
fc51111 Apr 26, 2022
23a5f67
LazyTest update
fc51111 Apr 27, 2022
acf5676
ResourceOptimism update
fc51111 Apr 27, 2022
e2dc635
Added serialVersionUID
fc51111 Apr 28, 2022
28a8270
Transient exceptions
fc51111 Apr 28, 2022
61a22f7
Fix Runtime Variable Exceptions
fc51111 May 1, 2022
2ace1b1
Individual Smells Secondary Criterion
fc51111 May 1, 2022
cef988f
Removed TestCodeDuplication
fc51111 May 1, 2022
b928ccd
Smells Secondary Objective default throw
fc51111 May 2, 2022
7bca87f
Update delta of asserts & description update
fc51111 May 2, 2022
4e73029
Include verbose with other smells
fc51111 May 3, 2022
5f12a1b
Combine test smells (unstable)
fc51111 May 5, 2022
f8ee30c
Removed option: "TEST_SMELL" secondary criteria
fc51111 May 5, 2022
677f74d
Secondary criteria normalized
fc51111 May 5, 2022
b05930f
Smell values clone correction
fc51111 May 5, 2022
17b6db4
Added serialVersion & getSmellType secondary objective
fc51111 May 7, 2022
17af78d
Updated several smell descriptions
fc51111 May 11, 2022
9f0408e
Update smell computation descriptions V1
fc51111 May 19, 2022
b53a5bd
Update all smells computation descriptions
fc51111 May 20, 2022
73f9b73
Print smells before minimization
fc51111 May 21, 2022
8ce65f7
Improved version of the dummy test
fc51111 May 23, 2022
55c23fb
Runtime variables update & corrections
fc51111 May 23, 2022
af2e3cc
BrittleAssertion & UnusedInputs description update
fc51111 May 23, 2022
da292b8
Print smells before post-processing
fc51111 May 24, 2022
c979bf9
Android (Paper): Update smell descriptions
fc51111 May 24, 2022
2d6d197
Small updates: smell descriptions
fc51111 May 25, 2022
e8d7938
LazyTest update
fc51111 May 26, 2022
e55ff88
Smells before post-processing (inside method)
fc51111 May 26, 2022
3894143
Update smell descriptions (avoid conflicts)
fc51111 Jun 8, 2022
78a009a
Added the tiebreaker for the secondary criteria
fc51111 Jun 8, 2022
65fe996
Print smells for each test case
fc51111 Jun 27, 2022
e5fc0a7
Print smells for each test case V2
fc51111 Jun 28, 2022
8b74a5a
Removed tiebreakers
fc51111 Jun 29, 2022
5849c63
Updates before RQ0
fc51111 Jun 30, 2022
5ae200c
Random secondary criterion
fc51111 Nov 30, 2022
c82e320
Use Randomness instead of Random
fc51111 Nov 30, 2022
df982fb
Removed some commented out code
fc51111 Feb 2, 2023
3b4fa71
Merge remote-tracking branch 'origin/master' into smell-free-tests
jose Jul 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.evosuite;

import org.evosuite.testsmells.AbstractTestSmell;
import org.evosuite.testsmells.smells.*;
import org.evosuite.testsuite.TestSuiteChromosome;

import java.util.ArrayList;
import java.util.List;

public class OptimizeTestSmellsPostProcessing {

private List<AbstractTestSmell> listOfTestSmells;

public OptimizeTestSmellsPostProcessing(){
initializeTestSmells();
}

private void initializeTestSmells(){
listOfTestSmells = new ArrayList<>();

listOfTestSmells.add(new AssertionRoulette());
listOfTestSmells.add(new DuplicateAssert());
listOfTestSmells.add(new EagerTest());
listOfTestSmells.add(new IndirectTesting());
listOfTestSmells.add(new LackOfCohesionOfMethods());
listOfTestSmells.add(new LazyTest());
listOfTestSmells.add(new LikelyIneffectiveObjectComparison());
listOfTestSmells.add(new ObscureInlineSetup());
listOfTestSmells.add(new Overreferencing());
listOfTestSmells.add(new RedundantAssertion());
listOfTestSmells.add(new RottenGreenTests());
listOfTestSmells.add(new TestRedundancy());
listOfTestSmells.add(new UnknownTest());
listOfTestSmells.add(new UnrelatedAssertions());
listOfTestSmells.add(new UnusedInputs());
listOfTestSmells.add(new VerboseTest());
}

public double computeTotalNumberOfSmells(TestSuiteChromosome testSuite){
double smellCount = testSuite.calculateSmellValuesTestSuiteUnrestricted(listOfTestSmells);

//Implement optimization

return smellCount;
}
}
23 changes: 22 additions & 1 deletion client/src/main/java/org/evosuite/Properties.java
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,11 @@ public enum MutationProbabilityDistribution {
public static MutationProbabilityDistribution MUTATION_PROBABILITY_DISTRIBUTION = MutationProbabilityDistribution.UNIFORM;

public enum SecondaryObjective {
AVG_LENGTH, MAX_LENGTH, TOTAL_LENGTH, SIZE, EXCEPTIONS, IBRANCH, RHO
AVG_LENGTH, MAX_LENGTH, TOTAL_LENGTH, SIZE, EXCEPTIONS, IBRANCH, RHO, TEST_SMELL_EAGER_TEST,
TEST_SMELL_EMPTY_TEST, TEST_SMELL_INDIRECT_TESTING, TEST_SMELL_LIKELY_INEFFECTIVE_OBJECT_COMPARISON,
TEST_SMELL_MYSTERY_GUEST, TEST_SMELL_OBSCURE_INLINE_SETUP, TEST_SMELL_OVERREFERENCING,
TEST_SMELL_RESOURCE_OPTIMISM, TEST_SMELL_ROTTEN_GREEN_TESTS, TEST_SMELL_SLOW_TESTS, TEST_SMELL_VERBOSE_TEST,
RANDOM
}

@Parameter(key = "secondary_objectives", group = "Search Algorithm", description = "Secondary objective during search")
Expand Down Expand Up @@ -981,6 +985,12 @@ public enum OutputFormat {
JUNIT3, JUNIT4, TESTNG, JUNIT5
}

@Parameter(key = "test_smell_optimization", group = "Output", description = "Optimize test smells as an additional post-processing step")
public static boolean TEST_SMELL_OPTIMIZATION = false;

@Parameter(key = "test_smell_list", group = "Output", description = "Show test smell list")
public static boolean TEST_SMELL_LIST = true;

@Parameter(key = "test_format", group = "Output", description = "Format of the resulting test cases")
public static OutputFormat TEST_FORMAT = OutputFormat.JUNIT4;

Expand Down Expand Up @@ -2175,6 +2185,17 @@ else if (f.getType().isArray()) {
}

f.set(this, criteria);
} else if (f.getType().getComponentType().equals(SecondaryObjective.class)) {
String[] values = value.split(":");
SecondaryObjective[] secondaryObjectives = new SecondaryObjective[values.length];

int pos = 0;
for (String stringValue : values) {
secondaryObjectives[pos++] = Enum.valueOf(SecondaryObjective.class,
stringValue.toUpperCase());
}

f.set(this, secondaryObjectives);
}
} else {
f.set(null, value);
Expand Down
Loading