Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/guillep/refactoring-mutation
https://github.com/guillep/refactoring-mutation
Last synced: 16 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/guillep/refactoring-mutation
- Owner: guillep
- License: mit
- Created: 2024-02-15T14:43:48.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-10-28T22:20:37.000Z (2 months ago)
- Last Synced: 2024-10-28T23:21:27.788Z (2 months ago)
- Language: Smalltalk
- Size: 116 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# refactoring-mutation
Loading the project:
```smalltalk
Metacello new
baseline: 'RefactoringTestExperiments';
repository: 'github://guillep/refactoring-mutation:main/src';
load
```## Examples
You can use `ExtractMethodMutationOperator` and `ExtractMethodNoPreconditionMutationOperator` as follows.
```smalltalk
testClasses := { UUIDPrimitivesTest }.
classesToMutate := {
UUID.
UUIDGenerator }.analysis := MTAnalysis new
classesToMutate: classesToMutate;
testClasses: testClasses;
operators: { ExtractMethodMutationOperator new }.analysis run.
"To inspect the results"
analysis generalResult inspect
``````smalltalk
testClasses := { UUIDPrimitivesTest }.
classesToMutate := {
UUID.
UUIDGenerator }.analysis := MTAnalysis new
classesToMutate: classesToMutate;
testClasses: testClasses;
operators: { ExtractMethodNoPreconditionMutationOperator new }.analysis run.
"To inspect the results"
analysis generalResult inspect
```## ExtractMethodMutationOperator
It is a semantic preserving mutation that systematically applies an extract method on each node it can.
As it is semantic preserving, it should not break any tests.
This means
- alive mutants mean *the refactoring works well for this case*
- killed mutants mean *there is a bug in the refactoring implementation*
- terminated mutant (the mutant could not be installed and run) *there is a bug in the refactoring implementation*## ExtractMethodNoPreconditionMutationOperator
It is a non-semantic preserving mutation that systematically applies an extract method on each node where it should not.
For this, we take into account refactoring preconditions.
If preconditions are met then we do not apply the refactoring.
If preconditions are not met we apply the refactoring.As it is non-semantic preserving, it behaves as normal mutations during mutation analysis.
This means
- alive mutants mean that either
- a test is missing
- or the code is equivalent (for example, if the extraction is on dead code)
- or the refactoring precondition is more conservative than it should (the refactoring is actually ok to perform but was being cancelled by a very conservative precondition) => this was actually a semantic-preserving transformation at the end
- killed mutants mean that preconditions protect us from a runtime mis-behavior. *the refactoring precondition is ok and prevents breaking the code in this way*
- terminated mutant (the mutant could not be installed and run) protect us from a compile-time mis-behavior. *the refactoring precondition is ok and prevents breaking the code in this way*