This repository has been archived by the owner on Mar 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor test specification export * wip: only testing is missing * add tests * change output folder of test (to bin_test) * remove duplicate files * fix imports
- Loading branch information
Showing
37 changed files
with
474 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/bin/ | ||
/generated/ | ||
/bin/ | ||
/generated/ | ||
/bin_test/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
bundles/specmate-testspecification/src/com/specmate/testspecification/api/ITestExporter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.specmate.testspecification.api; | ||
|
||
import com.specmate.model.testspecification.TestSpecificationSkeleton; | ||
|
||
public interface ITestExporter { | ||
|
||
/** getter for language */ | ||
String getLanguage(); | ||
|
||
/** Generates an export for the test specification */ | ||
TestSpecificationSkeleton generate(Object object); | ||
|
||
/** Signals that this exporter can export test specifications */ | ||
boolean canExportTestSpecification(); | ||
|
||
/** Signals that this exporter can export test procedures */ | ||
boolean canExportTestProcedure(); | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
...mate-testspecification/src/com/specmate/testspecification/api/ITestProcedureExporter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.specmate.testspecification.api; | ||
|
||
public interface ITestProcedureExporter { | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
bundles/specmate-testspecification/src/com/specmate/testspecification/api/packageinfo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
version 1.0.0 |
54 changes: 54 additions & 0 deletions
54
...ation/src/com/specmate/testspecification/internal/exporters/CSVTestProcedureExporter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.specmate.testspecification.internal.exporters; | ||
|
||
import static com.specmate.testspecification.internal.exporters.ExportUtil.CSV_COL_SEP; | ||
import static com.specmate.testspecification.internal.exporters.ExportUtil.CSV_LINE_SEP; | ||
|
||
import java.util.List; | ||
import java.util.StringJoiner; | ||
|
||
import org.osgi.service.component.annotations.Component; | ||
|
||
import com.specmate.model.support.util.SpecmateEcoreUtil; | ||
import com.specmate.model.testspecification.TestProcedure; | ||
import com.specmate.model.testspecification.TestSpecificationSkeleton; | ||
import com.specmate.model.testspecification.TestStep; | ||
import com.specmate.model.testspecification.TestspecificationFactory; | ||
import com.specmate.testspecification.api.ITestExporter; | ||
|
||
@Component(immediate = true) | ||
public class CSVTestProcedureExporter implements ITestExporter { | ||
private static final String HEADER = "Step Name" + CSV_COL_SEP + "Action" + CSV_COL_SEP + "Expected Outcome"; | ||
|
||
@Override | ||
public boolean canExportTestProcedure() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean canExportTestSpecification() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public String getLanguage() { | ||
return "csv"; | ||
} | ||
|
||
@Override | ||
public TestSpecificationSkeleton generate(Object object) { | ||
TestProcedure testprocedure = (TestProcedure) object; | ||
StringJoiner joiner = new StringJoiner(CSV_LINE_SEP); | ||
joiner.add(HEADER); | ||
List<TestStep> testSteps = SpecmateEcoreUtil.pickInstancesOf(testprocedure.getContents(), TestStep.class); | ||
for (TestStep step : testSteps) { | ||
joiner.add(step.getName() + CSV_COL_SEP + step.getDescription() + CSV_COL_SEP + step.getExpectedOutcome()); | ||
} | ||
TestSpecificationSkeleton skelleton = TestspecificationFactory.eINSTANCE.createTestSpecificationSkeleton(); | ||
skelleton.setName(ExportUtil.replaceInvalidChars(testprocedure.getName()) + ".csv"); | ||
skelleton.setLanguage(getLanguage()); | ||
skelleton.setCode(joiner.toString()); | ||
return skelleton; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...e-testspecification/src/com/specmate/testspecification/internal/exporters/ExportUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.specmate.testspecification.internal.exporters; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
/** Utility methods for exporting test specifications and procedures */ | ||
public class ExportUtil { | ||
|
||
/** Char to wrap text fields in */ | ||
public static final String CSV_TEXT_WRAP = "\""; | ||
/** Char to separate columns */ | ||
public static final String CSV_COL_SEP = ";"; | ||
/** Char used for line end */ | ||
public static final String CSV_LINE_SEP = "\n"; | ||
|
||
/** pattern that detects a number at the beginning */ | ||
private static Pattern startsNumerical = Pattern.compile("^[0-9]"); | ||
|
||
/** invalid characters for test names */ | ||
private static Pattern invalidChars = Pattern.compile("[^a-zA-Z_0-9\\_]"); | ||
|
||
/** Replaces potentially invalid characters for names */ | ||
public static String replaceInvalidChars(String name) { | ||
name = startsNumerical.matcher(name).replaceAll(""); | ||
return invalidChars.matcher(name).replaceAll("_"); | ||
} | ||
|
||
} |
15 changes: 11 additions & 4 deletions
15
...eleton/JavaTestSpecificationSkeleton.java → ...orters/JavaTestSpecificationExporter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 11 additions & 4 deletions
15
.../JavascriptTestSpecificationSkeleton.java → .../JavascriptTestSpecificationExporter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
.../internal/services/CEGNodeEvaluation.java → ...nternal/generators/CEGNodeEvaluation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.