Skip to content

Commit 9d45970

Browse files
committed
v0.0.4 complete
1 parent 855d3b5 commit 9d45970

File tree

7 files changed

+54
-9
lines changed

7 files changed

+54
-9
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>io.github.rsshekhawat</groupId>
55
<artifactId>cucumber-parallel-xbrowser-testing</artifactId>
66
<packaging>maven-plugin</packaging>
7-
<version>0.0.3</version>
7+
<version>0.0.4</version>
88
<name>cucumber-parallel-xbrowser-testing</name>
99
<url>https://github.com/rsshekhawat/cucumber-parallel-xbrowser-testing</url>
1010

src/main/java/io/github/rsshekhawat/MyMojo.java

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19+
import org.apache.commons.lang3.StringUtils;
1920
import org.apache.maven.plugin.AbstractMojo;
2021
import org.apache.maven.plugin.MojoExecution;
2122
import org.apache.maven.plugin.MojoExecutionException;
@@ -51,7 +52,7 @@ public class MyMojo extends AbstractMojo
5152
@Parameter(property = "configurationFilePath", required = true)
5253
private String configurationFilePath;
5354

54-
@Parameter(property = "includedTags", required = true)
55+
@Parameter(property = "includedTags")
5556
private String includedTags;
5657

5758
@Parameter( defaultValue = "${mojoExecution}", readonly = true )
@@ -88,6 +89,8 @@ public void execute() throws MojoExecutionException {
8889
public void createTestRunners() throws IOException {
8990

9091
String content = new String(Files.readAllBytes(Paths.get(templateRunnerPath)));
92+
content = ripOffPackageNameFromJavaFile(content);
93+
9194
File dir = new File(runnersDirectoryPath);
9295

9396
for(int i=0;i<totalFiles;i++) {
@@ -102,6 +105,19 @@ public void createTestRunners() throws IOException {
102105
getLog().info("Total Test Runners Created : "+totalFiles);
103106
}
104107

108+
public String ripOffPackageNameFromJavaFile(String content) throws IOException {
109+
110+
File file = new File(templateRunnerPath);
111+
String filePath = file.getCanonicalPath();
112+
filePath = filePath.replaceAll("\\\\",".");
113+
filePath = StringUtils.substringBetween(filePath,"src.test.java.","."+file.getName());
114+
115+
if(content.contains("package") && content.contains(filePath)) {
116+
content = content.replaceAll("package.*"+filePath+".*;","");
117+
}
118+
return content;
119+
}
120+
105121
public void createDataPropertiesFile() throws IOException {
106122

107123
File dir = new File(dataDirectoryPath);
@@ -114,7 +130,27 @@ public void createDataPropertiesFile() throws IOException {
114130
}
115131
}
116132

117-
public void addSpecificsToTestRunners() throws IOException {
133+
public void addSpecificsToTestRunnersForTextTemplateFile() throws IOException {
134+
135+
File folder = new File(runnersDirectoryPath);
136+
File[] listOfFiles = folder.listFiles();
137+
assert listOfFiles != null;
138+
139+
for (File file : listOfFiles) {
140+
if (file.isFile()) {
141+
Map<String, String> map = new HashMap<>();
142+
map.put("TEST_RUNNER_CLASS_NAME",file.getName().split("\\.")[0]);
143+
map.put("FEATURE_FILES_PATH", featureFilesPath);
144+
map.put("FEATURE_FILES_TAGS",includedTags);
145+
replaceTerms(file, map);
146+
}
147+
}
148+
}
149+
150+
public void addSpecificsToTestRunnersForJavaTemplateFile() throws IOException {
151+
152+
File javaFile = new File(templateRunnerPath);
153+
String javaFileName = javaFile.getName().split("\\.")[0];
118154

119155
File folder = new File(runnersDirectoryPath);
120156
File[] listOfFiles = folder.listFiles();
@@ -123,6 +159,7 @@ public void addSpecificsToTestRunners() throws IOException {
123159
for (File file : listOfFiles) {
124160
if (file.isFile()) {
125161
Map<String, String> map = new HashMap<>();
162+
map.put(javaFileName,file.getName().split("\\.")[0]);
126163
map.put("TEST_RUNNER_CLASS_NAME",file.getName().split("\\.")[0]);
127164
map.put("FEATURE_FILES_PATH", featureFilesPath);
128165
map.put("FEATURE_FILES_TAGS",includedTags);
@@ -131,6 +168,14 @@ public void addSpecificsToTestRunners() throws IOException {
131168
}
132169
}
133170

171+
public void addSpecificsToTestRunners() throws IOException {
172+
173+
if(templateRunnerPath.contains(".java"))
174+
addSpecificsToTestRunnersForJavaTemplateFile();
175+
else
176+
addSpecificsToTestRunnersForTextTemplateFile();
177+
}
178+
134179
public void replaceTerms(File file, Map<String, String> map) throws IOException {
135180

136181
StringBuilder oldContent = new StringBuilder();

target/classes/META-INF/maven/io.github.rsshekhawat/cucumber-parallel-xbrowser-testing/plugin-help.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<description>xbrowser parallel testing</description>
88
<groupId>io.github.rsshekhawat</groupId>
99
<artifactId>cucumber-parallel-xbrowser-testing</artifactId>
10-
<version>0.0.3</version>
10+
<version>0.0.4</version>
1111
<goalPrefix>cucumber-parallel-xbrowser-testing</goalPrefix>
1212
<mojos>
1313
<mojo>
@@ -42,7 +42,7 @@
4242
<parameter>
4343
<name>includedTags</name>
4444
<type>java.lang.String</type>
45-
<required>true</required>
45+
<required>false</required>
4646
<editable>true</editable>
4747
<description></description>
4848
</parameter>

target/classes/META-INF/maven/plugin.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<description>xbrowser parallel testing</description>
88
<groupId>io.github.rsshekhawat</groupId>
99
<artifactId>cucumber-parallel-xbrowser-testing</artifactId>
10-
<version>0.0.3</version>
10+
<version>0.0.4</version>
1111
<goalPrefix>cucumber-parallel-xbrowser-testing</goalPrefix>
1212
<isolatedRealm>false</isolatedRealm>
1313
<inheritedByDefault>true</inheritedByDefault>
@@ -44,7 +44,7 @@
4444
<parameter>
4545
<name>includedTags</name>
4646
<type>java.lang.String</type>
47-
<required>true</required>
47+
<required>false</required>
4848
<editable>true</editable>
4949
<description></description>
5050
</parameter>
1.25 KB
Binary file not shown.
-10.1 KB
Binary file not shown.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Generated by Maven
2-
#Wed Feb 09 11:51:32 IST 2022
3-
version=0.0.3
2+
#Fri Feb 11 23:45:41 IST 2022
3+
version=0.0.4
44
groupId=io.github.rsshekhawat
55
artifactId=cucumber-parallel-xbrowser-testing

0 commit comments

Comments
 (0)