Skip to content

Commit c21178a

Browse files
committed
cleanup after merge
1 parent d77768f commit c21178a

3 files changed

Lines changed: 115 additions & 69 deletions

File tree

config/neodymium.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166

167167
# Enables advanced screenshot capabilities with additional features
168168
# When set to true, provides more sophisticated screenshot taking mechanisms
169-
neodymium.screenshots.enableAdvancedScreenshots = true
169+
neodymium.screenshots.enableAdvancedScreenshots = false
170170

171171
# Controls whether screenshots are taken for successful test scenarios
172172
# When set to false, screenshots will not be captured for passing tests

src/test/java/com/xceptance/neodymium/util/LighthouseUtilsTest.java

Lines changed: 113 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -20,202 +20,249 @@ public void testLighthouseUtilsHappyPath() throws Exception
2020
Neodymium.configuration().setProperty("neodymium.lighthouse.assert.thresholdScore.accessiblity", "0.5");
2121
Neodymium.configuration().setProperty("neodymium.lighthouse.assert.thresholdScore.bestPractices", "0.5");
2222
Neodymium.configuration().setProperty("neodymium.lighthouse.assert.thresholdScore.seo", "0.5");
23-
23+
2424
Class<LighthouseUtils> clazz = LighthouseUtils.class;
2525
Method runProcess = clazz.getDeclaredMethod("runProcess", String[].class);
2626
runProcess.setAccessible(true);
2727
Process p = null;
28-
29-
if (System.getProperty("os.name").toLowerCase().contains("win"))
28+
29+
if (System.getProperty("os.name").toLowerCase().contains("win"))
3030
{
31-
Neodymium.configuration().setProperty("neodymium.lighthouse.binaryPath", "echo {\"categories\": {\"performance\": {\"score\": 0.5}, \"accessibility\": {\"score\": 0.5}, \"best-practices\": {\"score\": 0.5}, \"seo\": {\"score\": 0.5}}} > target/lighthouseUtilsReport.report.json | echo makeCommentWork #");
32-
p = (Process) runProcess.invoke(null, new Object[]{new String[]{"cmd.exe", "/c", "echo fabricatedHtml > target/lighthouseUtilsReport.report.html"}});
31+
Neodymium.configuration()
32+
.setProperty("neodymium.lighthouse.binaryPath",
33+
"echo {\"categories\": {\"performance\": {\"score\": 0.5}, \"accessibility\": {\"score\": 0.5}, \"best-practices\": {\"score\": 0.5}, \"seo\": {\"score\": 0.5}}} > target/lighthouseUtilsReport.report.json | echo makeCommentWork #");
34+
p = (Process) runProcess.invoke(null, new Object[]
35+
{
36+
new String[]
37+
{
38+
"cmd.exe", "/c", "echo fabricatedHtml > target/lighthouseUtilsReport.report.html"
39+
}
40+
});
3341
}
3442
else if (System.getProperty("os.name").toLowerCase().contains("linux") || System.getProperty("os.name").toLowerCase().contains("mac"))
3543
{
36-
try
44+
try
3745
{
38-
Neodymium.configuration().setProperty("neodymium.lighthouse.binaryPath", "echo {\"categories\": {\"performance\": {\"score\": 0.5}, \"accessibility\": {\"score\": 0.5}, \"best-practices\": {\"score\": 0.5}, \"seo\": {\"score\": 0.5}}} > target/lighthouseUtilsReport.report.json");
39-
p = (Process) runProcess.invoke(null, new Object[]{new String[]{"sh", "-c", "echo fabricatedHtml > target/lighthouseUtilsReport.report.html"}});
46+
Neodymium.configuration()
47+
.setProperty("neodymium.lighthouse.binaryPath",
48+
"echo {\"categories\": {\"performance\": {\"score\": 0.5}, \"accessibility\": {\"score\": 0.5}, \"best-practices\": {\"score\": 0.5}, \"seo\": {\"score\": 0.5}}} > target/lighthouseUtilsReport.report.json");
49+
p = (Process) runProcess.invoke(null, new Object[]
50+
{
51+
new String[]
52+
{
53+
"sh", "-c", "echo fabricatedHtml > target/lighthouseUtilsReport.report.html"
54+
}
55+
});
4056
}
41-
catch (Exception e)
57+
catch (Exception e)
4258
{
43-
p = (Process) runProcess.invoke(null, new Object[]{new String[]{"echo fabricatedHtml > target/lighthouseUtilsReport.report.html"}});
59+
p = (Process) runProcess.invoke(null, new Object[]
60+
{
61+
new String[]
62+
{
63+
"echo fabricatedHtml > target/lighthouseUtilsReport.report.html"
64+
}
65+
});
4466
}
4567
}
46-
else
68+
else
4769
{
4870
throw new Exception("your current operation system is not supported, please use Windows, Linux or MacOS");
4971
}
50-
72+
5173
BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
5274
while (r.readLine() != null)
5375
{
5476
continue;
5577
}
56-
78+
5779
Selenide.open("https://blog.xceptance.com/");
58-
80+
5981
LighthouseUtils.createLightHouseReport("lighthouseUtilsReport");
6082
}
61-
83+
6284
@NeodymiumTest
6385
public void testLighthouseUtilsPerformanceException() throws Exception
6486
{
6587
Neodymium.configuration().setProperty("neodymium.lighthouse.assert.thresholdScore.performance", "0.51");
6688
Neodymium.configuration().setProperty("neodymium.lighthouse.assert.thresholdScore.accessibility", "0.5");
6789
Neodymium.configuration().setProperty("neodymium.lighthouse.assert.thresholdScore.bestPractices", "0.5");
6890
Neodymium.configuration().setProperty("neodymium.lighthouse.assert.thresholdScore.seo", "0.5");
69-
70-
if (System.getProperty("os.name").toLowerCase().contains("win"))
91+
92+
if (System.getProperty("os.name").toLowerCase().contains("win"))
7193
{
72-
Neodymium.configuration().setProperty("neodymium.lighthouse.binaryPath", "echo {\"categories\": {\"performance\": {\"score\": 0.5}, \"accessibility\": {\"score\": 0.5}, \"best-practices\": {\"score\": 0.5}, \"seo\": {\"score\": 0.5}}} > target/lighthouseUtilsReport.report.json | echo makeCommentWork #");
94+
Neodymium.configuration()
95+
.setProperty("neodymium.lighthouse.binaryPath",
96+
"echo {\"categories\": {\"performance\": {\"score\": 0.5}, \"accessibility\": {\"score\": 0.5}, \"best-practices\": {\"score\": 0.5}, \"seo\": {\"score\": 0.5}}} > target/lighthouseUtilsReport.report.json | echo makeCommentWork #");
7397
}
7498
else if (System.getProperty("os.name").toLowerCase().contains("linux") || System.getProperty("os.name").toLowerCase().contains("mac"))
7599
{
76-
Neodymium.configuration().setProperty("neodymium.lighthouse.binaryPath", "echo {\"categories\": {\"performance\": {\"score\": 0.5}, \"accessibility\": {\"score\": 0.5}, \"best-practices\": {\"score\": 0.5}, \"seo\": {\"score\": 0.5}}} > target/lighthouseUtilsReport.report.json");
100+
Neodymium.configuration()
101+
.setProperty("neodymium.lighthouse.binaryPath",
102+
"echo {\"categories\": {\"performance\": {\"score\": 0.5}, \"accessibility\": {\"score\": 0.5}, \"best-practices\": {\"score\": 0.5}, \"seo\": {\"score\": 0.5}}} > target/lighthouseUtilsReport.report.json");
77103
}
78-
else
104+
else
79105
{
80106
throw new Exception("your current operation system is not supported, please use Windows, Linux or MacOS");
81107
}
82-
108+
83109
Selenide.open("https://blog.xceptance.com/");
84-
85-
try
110+
111+
try
86112
{
87113
LighthouseUtils.createLightHouseReport("lighthouseUtilsReport");
88114
}
89-
catch (AssertionError e)
115+
catch (AssertionError e)
90116
{
91-
Assert.assertTrue("the compared error messages doesn't match", e.getMessage().contains("The Lighthouse performance score 0.5 doesn't exceed nor match the required threshold of 0.51, please improve the score to match expectations"));
117+
Assert.assertTrue("the compared error messages doesn't match",
118+
e.getMessage()
119+
.contains("The Lighthouse performance score 0.5 doesn't exceed nor match the required threshold of 0.51, please improve the score to match expectations"));
92120
}
93121
}
94-
122+
95123
@NeodymiumTest
96124
public void testLighthouseUtilsAccessibilityException() throws Exception
97125
{
98126
Neodymium.configuration().setProperty("neodymium.lighthouse.assert.thresholdScore.performance", "0.5");
99127
Neodymium.configuration().setProperty("neodymium.lighthouse.assert.thresholdScore.accessibility", "0.51");
100128
Neodymium.configuration().setProperty("neodymium.lighthouse.assert.thresholdScore.bestPractices", "0.5");
101129
Neodymium.configuration().setProperty("neodymium.lighthouse.assert.thresholdScore.seo", "0.5");
102-
103-
if (System.getProperty("os.name").toLowerCase().contains("win"))
130+
131+
if (System.getProperty("os.name").toLowerCase().contains("win"))
104132
{
105-
Neodymium.configuration().setProperty("neodymium.lighthouse.binaryPath", "echo {\"categories\": {\"performance\": {\"score\": 0.5}, \"accessibility\": {\"score\": 0.5}, \"best-practices\": {\"score\": 0.5}, \"seo\": {\"score\": 0.5}}} > target/lighthouseUtilsReport.report.json | echo makeCommentWork #");
133+
Neodymium.configuration()
134+
.setProperty("neodymium.lighthouse.binaryPath",
135+
"echo {\"categories\": {\"performance\": {\"score\": 0.5}, \"accessibility\": {\"score\": 0.5}, \"best-practices\": {\"score\": 0.5}, \"seo\": {\"score\": 0.5}}} > target/lighthouseUtilsReport.report.json | echo makeCommentWork #");
106136
}
107137
else if (System.getProperty("os.name").toLowerCase().contains("linux") || System.getProperty("os.name").toLowerCase().contains("mac"))
108138
{
109-
Neodymium.configuration().setProperty("neodymium.lighthouse.binaryPath", "echo {\"categories\": {\"performance\": {\"score\": 0.5}, \"accessibility\": {\"score\": 0.5}, \"best-practices\": {\"score\": 0.5}, \"seo\": {\"score\": 0.5}}} > target/lighthouseUtilsReport.report.json");
139+
Neodymium.configuration()
140+
.setProperty("neodymium.lighthouse.binaryPath",
141+
"echo {\"categories\": {\"performance\": {\"score\": 0.5}, \"accessibility\": {\"score\": 0.5}, \"best-practices\": {\"score\": 0.5}, \"seo\": {\"score\": 0.5}}} > target/lighthouseUtilsReport.report.json");
110142
}
111-
else
143+
else
112144
{
113145
throw new Exception("your current operation system is not supported, please use Windows, Linux or MacOS");
114146
}
115-
147+
116148
Selenide.open("https://blog.xceptance.com/");
117-
118-
try
149+
150+
try
119151
{
120152
LighthouseUtils.createLightHouseReport("lighthouseUtilsReport");
121153
}
122-
catch (AssertionError e)
154+
catch (AssertionError e)
123155
{
124-
Assert.assertTrue("the compared error messages doesn't match", e.getMessage().contains("The Lighthouse accessibility score 0.5 doesn't exceed nor match the required threshold of 0.51, please improve the score to match expectations"));
156+
Assert.assertTrue("the compared error messages doesn't match",
157+
e.getMessage()
158+
.contains("The Lighthouse accessibility score 0.5 doesn't exceed nor match the required threshold of 0.51, please improve the score to match expectations"));
125159
}
126160
}
127-
161+
128162
@NeodymiumTest
129163
public void testLighthouseUtilsBestPracticesException() throws Exception
130164
{
131165
Neodymium.configuration().setProperty("neodymium.lighthouse.assert.thresholdScore.performance", "0.5");
132166
Neodymium.configuration().setProperty("neodymium.lighthouse.assert.thresholdScore.accessibility", "0.5");
133167
Neodymium.configuration().setProperty("neodymium.lighthouse.assert.thresholdScore.bestPractices", "0.51");
134168
Neodymium.configuration().setProperty("neodymium.lighthouse.assert.thresholdScore.seo", "0.5");
135-
136-
if (System.getProperty("os.name").toLowerCase().contains("win"))
169+
170+
if (System.getProperty("os.name").toLowerCase().contains("win"))
137171
{
138-
Neodymium.configuration().setProperty("neodymium.lighthouse.binaryPath", "echo {\"categories\": {\"performance\": {\"score\": 0.5}, \"accessibility\": {\"score\": 0.5}, \"best-practices\": {\"score\": 0.5}, \"seo\": {\"score\": 0.5}}} > target/lighthouseUtilsReport.report.json | echo makeCommentWork #");
172+
Neodymium.configuration()
173+
.setProperty("neodymium.lighthouse.binaryPath",
174+
"echo {\"categories\": {\"performance\": {\"score\": 0.5}, \"accessibility\": {\"score\": 0.5}, \"best-practices\": {\"score\": 0.5}, \"seo\": {\"score\": 0.5}}} > target/lighthouseUtilsReport.report.json | echo makeCommentWork #");
139175
}
140176
else if (System.getProperty("os.name").toLowerCase().contains("linux") || System.getProperty("os.name").toLowerCase().contains("mac"))
141177
{
142-
Neodymium.configuration().setProperty("neodymium.lighthouse.binaryPath", "echo {\"categories\": {\"performance\": {\"score\": 0.5}, \"accessibility\": {\"score\": 0.5}, \"best-practices\": {\"score\": 0.5}, \"seo\": {\"score\": 0.5}}} > target/lighthouseUtilsReport.report.json");
178+
Neodymium.configuration()
179+
.setProperty("neodymium.lighthouse.binaryPath",
180+
"echo {\"categories\": {\"performance\": {\"score\": 0.5}, \"accessibility\": {\"score\": 0.5}, \"best-practices\": {\"score\": 0.5}, \"seo\": {\"score\": 0.5}}} > target/lighthouseUtilsReport.report.json");
143181
}
144-
else
182+
else
145183
{
146184
throw new Exception("your current operation system is not supported, please use Windows, Linux or MacOS");
147185
}
148-
186+
149187
Selenide.open("https://blog.xceptance.com/");
150-
151-
try
188+
189+
try
152190
{
153191
LighthouseUtils.createLightHouseReport("lighthouseUtilsReport");
154192
}
155-
catch (AssertionError e)
193+
catch (AssertionError e)
156194
{
157-
Assert.assertTrue("the compared error messages doesn't match", e.getMessage().contains("The Lighthouse best practices score 0.5 doesn't exceed nor match the required threshold of 0.51, please improve the score to match expectations"));
195+
Assert.assertTrue("the compared error messages doesn't match",
196+
e.getMessage()
197+
.contains("The Lighthouse best practices score 0.5 doesn't exceed nor match the required threshold of 0.51, please improve the score to match expectations"));
158198
}
159199
}
160-
200+
161201
@NeodymiumTest
162202
public void testLighthouseUtilsSeoException() throws Exception
163203
{
164204
Neodymium.configuration().setProperty("neodymium.lighthouse.assert.thresholdScore.performance", "0.5");
165205
Neodymium.configuration().setProperty("neodymium.lighthouse.assert.thresholdScore.accessibility", "0.5");
166206
Neodymium.configuration().setProperty("neodymium.lighthouse.assert.thresholdScore.bestPractices", "0.5");
167207
Neodymium.configuration().setProperty("neodymium.lighthouse.assert.thresholdScore.seo", "0.51");
168-
169-
if (System.getProperty("os.name").toLowerCase().contains("win"))
208+
209+
if (System.getProperty("os.name").toLowerCase().contains("win"))
170210
{
171-
Neodymium.configuration().setProperty("neodymium.lighthouse.binaryPath", "echo {\"categories\": {\"performance\": {\"score\": 0.5}, \"accessibility\": {\"score\": 0.5}, \"best-practices\": {\"score\": 0.5}, \"seo\": {\"score\": 0.5}}} > target/lighthouseUtilsReport.report.json | echo makeCommentWork #");
211+
Neodymium.configuration()
212+
.setProperty("neodymium.lighthouse.binaryPath",
213+
"echo {\"categories\": {\"performance\": {\"score\": 0.5}, \"accessibility\": {\"score\": 0.5}, \"best-practices\": {\"score\": 0.5}, \"seo\": {\"score\": 0.5}}} > target/lighthouseUtilsReport.report.json | echo makeCommentWork #");
172214
}
173215
else if (System.getProperty("os.name").toLowerCase().contains("linux") || System.getProperty("os.name").toLowerCase().contains("mac"))
174216
{
175-
Neodymium.configuration().setProperty("neodymium.lighthouse.binaryPath", "echo {\"categories\": {\"performance\": {\"score\": 0.5}, \"accessibility\": {\"score\": 0.5}, \"best-practices\": {\"score\": 0.5}, \"seo\": {\"score\": 0.5}}} > target/lighthouseUtilsReport.report.json");
217+
Neodymium.configuration()
218+
.setProperty("neodymium.lighthouse.binaryPath",
219+
"echo {\"categories\": {\"performance\": {\"score\": 0.5}, \"accessibility\": {\"score\": 0.5}, \"best-practices\": {\"score\": 0.5}, \"seo\": {\"score\": 0.5}}} > target/lighthouseUtilsReport.report.json");
176220
}
177-
else
221+
else
178222
{
179223
throw new Exception("your current operation system is not supported, please use Windows, Linux or MacOS");
180224
}
181-
225+
182226
Selenide.open("https://blog.xceptance.com/");
183-
184-
try
227+
228+
try
185229
{
186230
LighthouseUtils.createLightHouseReport("lighthouseUtilsReport");
187231
}
188-
catch (AssertionError e)
232+
catch (AssertionError e)
189233
{
190-
Assert.assertTrue("the compared error messages doesn't match", e.getMessage().contains("The Lighthouse seo score 0.5 doesn't exceed nor match the required threshold of 0.51, please improve the score to match expectations"));
234+
Assert.assertTrue("the compared error messages doesn't match",
235+
e.getMessage()
236+
.contains("The Lighthouse seo score 0.5 doesn't exceed nor match the required threshold of 0.51, please improve the score to match expectations"));
191237
}
192238
}
193-
239+
194240
@NeodymiumTest
195241
public void testLighthouseUtilsBinNotFound() throws Exception
196242
{
197-
if (System.getProperty("os.name").toLowerCase().contains("win"))
243+
if (System.getProperty("os.name").toLowerCase().contains("win"))
198244
{
199245
Neodymium.configuration().setProperty("neodymium.lighthouse.binaryPath", "programmWhichIsDefinitelyNotInstalled");
200246
}
201247
else if (System.getProperty("os.name").toLowerCase().contains("linux") || System.getProperty("os.name").toLowerCase().contains("mac"))
202248
{
203249
Neodymium.configuration().setProperty("neodymium.lighthouse.binaryPath", "programmWhichIsDefinitelyNotInstalled");
204250
}
205-
else
251+
else
206252
{
207253
throw new Exception("your current operation system is not supported, please use Windows, Linux or MacOS");
208254
}
209-
255+
210256
Selenide.open("https://blog.xceptance.com/");
211-
212-
try
257+
258+
try
213259
{
214260
LighthouseUtils.createLightHouseReport("lighthouseUtilsReport");
215261
}
216-
catch (Exception e)
262+
catch (Exception e)
217263
{
218-
Assert.assertTrue("the compared error messages doesn't match", e.getMessage().contains("lighthouse binary not found at"));
264+
Assert.assertTrue("the compared error messages doesn't match",
265+
e.getMessage().contains("please install lighthouse and add it to the PATH or enter the correct lighthouse binary location"));
219266
}
220267
}
221268
}

src/test/java/com/xceptance/neodymium/util/SelenideErrorDetailsFormatterTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public void testCollectionErrorDetailesDeactivated()
8282
public void testCollectionErrorDetailesActivated()
8383
{
8484
Neodymium.configuration().setProperty("neodymium.report.showSelenideErrorDetails", "true");
85+
Neodymium.configuration().setProperty("neodymium.screenshots.enableAdvancedScreenshots", "false");
8586
Assertions.assertTrue(Neodymium.configuration().showSelenideErrorDetails());
8687

8788
try
@@ -91,9 +92,7 @@ public void testCollectionErrorDetailesActivated()
9192
}
9293
catch (AssertionError e)
9394
{
94-
System.out.println(e.getMessage());
9595
assertExpectedMessageContains(e.getMessage(), "List size mismatch: expected: > 5, actual: 0, collection: #someUnknownIDForThisSepcificTest\n");
96-
assertExpectedMessageContains(e.getMessage(), "Screenshot: ");
9796
assertExpectedMessageContains(e.getMessage(), "Page source: ");
9897
assertExpectedMessageContains(e.getMessage(), "Timeout: 0 ms.");
9998
}

0 commit comments

Comments
 (0)