-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#198] improve junit4 tests and add tests for junit5
- Loading branch information
1 parent
2853495
commit 675ed73
Showing
4 changed files
with
144 additions
and
13 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
55 changes: 55 additions & 0 deletions
55
.../java/com/xceptance/neodymium/junit5/testclasses/webDriver/DriverArgumentsConfigTest.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,55 @@ | ||
package com.xceptance.neodymium.junit5.testclasses.webDriver; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
|
||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.Assertions; | ||
|
||
import com.codeborne.selenide.Selenide; | ||
import com.xceptance.neodymium.common.browser.Browser; | ||
import com.xceptance.neodymium.junit5.NeodymiumTest; | ||
import com.xceptance.neodymium.junit5.tests.DriverArgumentsTest; | ||
import com.xceptance.neodymium.util.Neodymium; | ||
|
||
@Browser("FF_with_args") | ||
@Browser("Chrome_with_args") | ||
public class DriverArgumentsConfigTest | ||
{ | ||
private File chromeLogFile = new File(DriverArgumentsTest.logFileNameChrome); | ||
|
||
private File firefoxLogFile = new File(DriverArgumentsTest.logFileNameFirefox); | ||
|
||
@NeodymiumTest | ||
public void test() throws IOException | ||
{ | ||
Selenide.open("https://www.xceptance.com/en/"); | ||
if (Neodymium.getBrowserName().equals("chrome")) | ||
{ | ||
Assertions.assertTrue(chromeLogFile.exists(), "No log file found for chrome"); | ||
Assertions.assertTrue(Files.readString(chromeLogFile.toPath()).contains(DriverArgumentsTest.chromePort), "No log file found for chrome"); | ||
} | ||
else | ||
{ | ||
Assertions.assertTrue(new File(DriverArgumentsTest.logFileNameFirefox).exists(), "No log file found for firefox"); | ||
Assertions.assertTrue(Files.readString(firefoxLogFile.toPath()).contains(DriverArgumentsTest.firefoxPort), "Port not found in firefox log"); | ||
Assertions.assertTrue(Files.readString(firefoxLogFile.toPath()).contains(DriverArgumentsTest.firefoxWebsocketPort), | ||
"Websocket port not found in firefox log"); | ||
} | ||
} | ||
|
||
@AfterEach | ||
public void cleanup() | ||
{ | ||
if (chromeLogFile.exists()) | ||
{ | ||
chromeLogFile.delete(); | ||
} | ||
|
||
if (firefoxLogFile.exists()) | ||
{ | ||
firefoxLogFile.delete(); | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/test/java/com/xceptance/neodymium/junit5/tests/DriverArgumentsTest.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,58 @@ | ||
package com.xceptance.neodymium.junit5.tests; | ||
|
||
import java.io.File; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import com.xceptance.neodymium.junit5.testclasses.webDriver.DriverArgumentsConfigTest; | ||
import com.xceptance.neodymium.junit5.tests.utils.NeodymiumTestExecutionSummary; | ||
|
||
public class DriverArgumentsTest extends AbstractNeodymiumTest | ||
{ | ||
public static String logFileNameChrome = "target/" + UUID.randomUUID().toString() + "_chrome.log"; | ||
|
||
public static String logFileNameFirefox = "target/" + UUID.randomUUID().toString() + "_firefox.log"; | ||
|
||
public static String chromePort = "7100"; | ||
|
||
public static String firefoxPort = "8525"; | ||
|
||
public static String firefoxWebsocketPort = "8785"; | ||
|
||
@BeforeAll | ||
public static void createSettings() | ||
{ | ||
Map<String, String> properties3 = new HashMap<>(); | ||
|
||
properties3.put("browserprofile.FF_with_args.name", "FF with args"); | ||
properties3.put("browserprofile.FF_with_args.headless", "true"); | ||
properties3.put("browserprofile.FF_with_args.browserResolution", "1024x768"); | ||
properties3.put("browserprofile.FF_with_args.browser", "firefox"); | ||
properties3.put("browserprofile.FF_with_args.driverArgs", | ||
"--log ; info ;--allow-hosts; xceptance.com; google.com; --port=" + firefoxPort | ||
+ "; --log-no-truncate ; --websocket-port=" + firefoxWebsocketPort | ||
+ "; --allow-origins; http://xceptance.com:8785 ; --log-path=" | ||
+ logFileNameFirefox); | ||
|
||
properties3.put("browserprofile.Chrome_with_args.name", "Chrome with args"); | ||
properties3.put("browserprofile.Chrome_with_args.headless", "true"); | ||
properties3.put("browserprofile.Chrome_with_args.browserResolution", "1024x768"); | ||
properties3.put("browserprofile.Chrome_with_args.browser", "chrome"); | ||
properties3.put("browserprofile.Chrome_with_args.driverArgs", | ||
"--port=" + chromePort + "; --allowed-origins=localhost, xceptance.com; --log-level=INFO ; --log-path=" + logFileNameChrome); | ||
File tempConfigFile3 = new File("./config/dev-browser.properties"); | ||
writeMapToPropertiesFile(properties3, tempConfigFile3); | ||
tempFiles.add(tempConfigFile3); | ||
} | ||
|
||
@Test | ||
public void test() | ||
{ | ||
NeodymiumTestExecutionSummary result = run(DriverArgumentsConfigTest.class); | ||
checkPass(result, 2, 0); | ||
} | ||
} |