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

Support for multiple reports with different granularity (file, class, method) #9

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
29d6a9b
AbstractSmell became interface, getHasSmell and getHasProductionFile …
victorgveloso Aug 26, 2020
b33956d
Moved Util members to AbstractSmell (making it abstract class again),…
victorgveloso Aug 26, 2020
287a2fb
Pulled smellyElement member up to AbstractSmell, Moved with delegatio…
victorgveloso Aug 26, 2020
9ba345a
Refactored Main.java, renamed some methods (TestSmellDetector.addSmel…
victorgveloso Aug 26, 2020
3497f82
Implemented MethodValidator and TestSmellDetector unit tests, added '…
victorgveloso Aug 26, 2020
b67eed0
Removed writeOutput aliases on ResultsWriter, renamed writeOutput to …
victorgveloso Aug 27, 2020
0a8a036
Extracted super class SmellsContainer from TestFile (use it on Result…
victorgveloso Aug 27, 2020
3e7eb48
A relative file path without separator is equal to the filename, a fi…
victorgveloso Aug 27, 2020
4821c62
On TestFile constructor, file without extension and path without sepa…
victorgveloso Aug 27, 2020
aa1fe2d
SmellsContainer became an interface with default methods and it's sup…
victorgveloso Aug 28, 2020
e2e6bd3
New class extracted from Main. It will handle report granularity-leve…
victorgveloso Aug 28, 2020
1825641
ExportingGranularityController renamed to ReportController, report gr…
victorgveloso Aug 28, 2020
c750a85
IntegrationTest implemented for TestSmellDetector.detectSmells (tagge…
victorgveloso Aug 28, 2020
1ee8b41
Renamed TestSmellDetectorIT.testSmellDetector to 'testSmellsFreeProje…
victorgveloso Aug 30, 2020
871a284
Optimized AbstractSmell.hasSmell, made prodFile optional, merging sam…
victorgveloso Sep 18, 2020
81b1eaa
Breaking change: no null should be added as testFile's smells on Test…
victorgveloso Sep 18, 2020
ff64c7d
Tests implemented for each TestSmell (production file specified only …
victorgveloso Sep 18, 2020
d24a6eb
ReportController new constructor receive granularities list, relative…
victorgveloso Sep 25, 2020
4f1e412
Implemented merge of smells with same name on report
victorgveloso Sep 26, 2020
8df9dc7
Reimplemented merging, fixing repeated entry and wrong smellPresence
victorgveloso Sep 26, 2020
f0d1c34
Extracted Report formatting from ReportController and refactored code
victorgveloso Sep 26, 2020
833911e
Adapted tests to ignore outputted Smells order (this is still WIP)
victorgveloso Sep 26, 2020
f5b3178
Fixed some warnings
victorgveloso Sep 26, 2020
d36797b
CSV header generated after smell detection + method compatibility
victorgveloso Sep 27, 2020
ea58040
Removed ResultsWriter dependency TestSmellDetector
victorgveloso Sep 27, 2020
2a357fd
TestMethod full name (package.class.method) retrieved for uniqueness
victorgveloso Sep 27, 2020
7e8e887
full class name (package.class) retrieved too; made methods more generic
victorgveloso Sep 27, 2020
57c0335
Implemented simultaneous multiple output granularities
victorgveloso Sep 27, 2020
3723487
fixed ConstructorInitializationIntegrationTest, added class granulari…
victorgveloso Sep 28, 2020
f17e982
ReportControllerIntegrationTests better organized (split in 3 classes…
victorgveloso Sep 28, 2020
daecf80
Enhanced ReportControllerIntegrationTests organization even more!
victorgveloso Sep 28, 2020
c2a994c
Make all granularities enabled by default and updated project version.
victorgveloso Sep 28, 2020
d972bd3
Fixed outputting header repeatedly for each inputted TestFile; Optimi…
victorgveloso Oct 25, 2020
15d7a5d
Fixed multi-file repeated report entries:
victorgveloso Oct 25, 2020
3073395
Implemented failing tests for class granularity report and fixed Depe…
victorgveloso Oct 26, 2020
9d11c39
Fixed ConstructorInitialization omission on failure
victorgveloso Oct 27, 2020
d3d27a7
Fixed DefaultTest and IgnoredTest omission/null on failure; added sup…
victorgveloso Oct 27, 2020
beeae67
Updated maven project version
victorgveloso Oct 27, 2020
233f1c1
Added Anonymous class handling at AbstractSmell.getFullMethodName
victorgveloso Oct 27, 2020
397e840
Maven patch version increased
victorgveloso Oct 27, 2020
264f657
Renamed AssertCount to BadAssertCount and added TotalAssertCount
victorgveloso Jun 25, 2021
d30bc86
Added final modifier to TestSmellDetector class
victorgveloso Jun 25, 2021
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
576 changes: 121 additions & 455 deletions class_diagram.uml

Large diffs are not rendered by default.

62 changes: 56 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,26 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>edu.rit.se.testsmells</groupId>
<artifactId>TestSmellDetector</artifactId>
<version>0.1</version>
<version>0.3.2</version>
<packaging>jar</packaging>
<properties>
<project.MainClass>edu.rit.se.testsmells.Main</project.MainClass>
</properties>
<build>
<resources>
<resource>
<directory>src/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -29,6 +43,21 @@
<version>5.4.2</version>
</dependency>
</dependencies>
<configuration>
<excludedGroups>integration</excludedGroups>
<argLine>--illegal-access=permit</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>${project.MainClass}</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -42,9 +71,7 @@
<configuration>
<archive>
<manifest>
<mainClass>
Main
</mainClass>
<mainClass>${project.MainClass}</mainClass>
</manifest>
</archive>
<descriptorRefs>
Expand All @@ -56,6 +83,23 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>integration</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<groups>integration</groups>
<excludedGroups>none</excludedGroups>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<dependencies>
<dependency>
Expand All @@ -80,12 +124,18 @@
<version>5.4.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.5.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.4.2</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
112 changes: 0 additions & 112 deletions src/main/java/Main.java

This file was deleted.

102 changes: 102 additions & 0 deletions src/main/java/edu/rit/se/testsmells/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package edu.rit.se.testsmells;

import edu.rit.se.testsmells.testsmell.CSVWriter;
import edu.rit.se.testsmells.testsmell.ReportController;
import edu.rit.se.testsmells.testsmell.TestFile;
import edu.rit.se.testsmells.testsmell.TestSmellDetector;
import edu.rit.se.testsmells.testsmell.smell.*;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Main {
public static void main(String[] args) throws IOException {
File inputFile = handleCliArgs(args);

TestSmellDetector testSmellDetector = initializeSmells();

List<TestFile> files = readInputTestFiles(inputFile);
CSVWriter csvWriter = CSVWriter.createResultsWriter();
ReportController reportCtrl = ReportController.createReportController(csvWriter);

for (TestFile file : files) {
System.out.println(getCurrentDateFormatted() + " Processing: " + file.getTestFilePath());
testSmellDetector.detectSmells(file);
}

reportCtrl.report(files);

System.out.println("end");
}

private static Object getCurrentDateFormatted() {
return (new SimpleDateFormat("yyyy/MM/dd HH:mm:ss")).format(new Date());
}

private static List<TestFile> readInputTestFiles(File inputFile) throws IOException {
BufferedReader in = new BufferedReader(new FileReader(inputFile));
String str;

String[] lineItem;
TestFile testFile;
List<TestFile> testFiles = new ArrayList<>();
while ((str = in.readLine()) != null) {
// use comma as separator
lineItem = str.split(",");

//check if the test file has an associated production file
if (lineItem.length == 2) {
testFile = new TestFile(lineItem[0], lineItem[1], "");
} else {
testFile = new TestFile(lineItem[0], lineItem[1], lineItem[2]);
}

testFiles.add(testFile);
}
return testFiles;
}

private static File handleCliArgs(String[] args) {
assert args != null && args.length > 0 && args[0].isEmpty() : "Please provide the file containing the paths to the collection of test files";
File inputFile = new File(args[0]);
assert inputFile.exists() && !inputFile.isDirectory() : "Please provide a valid file containing the paths to the collection of test files";

return inputFile;
}

private static TestSmellDetector initializeSmells() {
TestSmellDetector testSmellDetector = TestSmellDetector.createTestSmellDetector();

testSmellDetector.addDetectableSmell(new AssertionRoulette());
testSmellDetector.addDetectableSmell(new ConditionalTestLogic());
testSmellDetector.addDetectableSmell(new ConstructorInitialization());
testSmellDetector.addDetectableSmell(new DefaultTest());
testSmellDetector.addDetectableSmell(new EmptyTest());
testSmellDetector.addDetectableSmell(new ExceptionCatchingThrowing());
testSmellDetector.addDetectableSmell(new GeneralFixture());
testSmellDetector.addDetectableSmell(new MysteryGuest());
testSmellDetector.addDetectableSmell(new PrintStatement());
testSmellDetector.addDetectableSmell(new RedundantAssertion());
testSmellDetector.addDetectableSmell(new SensitiveEquality());
testSmellDetector.addDetectableSmell(new VerboseTest());
testSmellDetector.addDetectableSmell(new SleepyTest());
testSmellDetector.addDetectableSmell(new EagerTest());
testSmellDetector.addDetectableSmell(new LazyTest());
testSmellDetector.addDetectableSmell(new DuplicateAssert());
testSmellDetector.addDetectableSmell(new UnknownTest());
testSmellDetector.addDetectableSmell(new IgnoredTest());
testSmellDetector.addDetectableSmell(new ResourceOptimism());
testSmellDetector.addDetectableSmell(new MagicNumberTest());
testSmellDetector.addDetectableSmell(new DependentTest());

return testSmellDetector;
}


}
Loading