Revize 2739d159
Přidáno uživatelem Petr Urban před téměř 3 roky(ů)
pom.xml | ||
---|---|---|
85 | 85 |
<version>5.4.0</version> |
86 | 86 |
<scope>test</scope> |
87 | 87 |
</dependency> |
88 |
|
|
89 |
|
|
90 |
<!-- UI TESTING --> |
|
91 |
<dependency> |
|
92 |
<groupId>org.seleniumhq.selenium</groupId> |
|
93 |
<artifactId>selenium-java</artifactId> |
|
94 |
<version>3.141.59</version> <!-- HIGHER VERSION 4+ are not compatible with webdrivermanager plugin --> |
|
95 |
</dependency> |
|
96 |
|
|
97 |
<dependency> |
|
98 |
<groupId>io.github.bonigarcia</groupId> |
|
99 |
<artifactId>webdrivermanager</artifactId> |
|
100 |
<version>5.2.0</version> |
|
101 |
<scope>test</scope> |
|
102 |
</dependency> |
|
103 |
|
|
88 | 104 |
</dependencies> |
89 | 105 |
|
90 | 106 |
<build> |
src/test/java/cz/zcu/fav/kiv/antipatterndetectionapp/uitests/UITestRunner.java | ||
---|---|---|
1 |
package cz.zcu.fav.kiv.antipatterndetectionapp.uitests; |
|
2 |
|
|
3 |
import io.github.bonigarcia.wdm.WebDriverManager; |
|
4 |
import org.junit.jupiter.api.*; |
|
5 |
import org.openqa.selenium.By; |
|
6 |
import org.openqa.selenium.WebDriver; |
|
7 |
import org.openqa.selenium.WebElement; |
|
8 |
import org.openqa.selenium.chrome.ChromeDriver; |
|
9 |
|
|
10 |
import java.time.Duration; |
|
11 |
import java.util.Locale; |
|
12 |
import java.util.concurrent.TimeUnit; |
|
13 |
|
|
14 |
import static org.assertj.core.api.Assertions.assertThat; |
|
15 |
|
|
16 |
|
|
17 |
/** |
|
18 |
* Main class for UI testing scenarios |
|
19 |
* |
|
20 |
* @author Petr Urban |
|
21 |
* @version 1.0 |
|
22 |
*/ |
|
23 |
public class UITestRunner { |
|
24 |
|
|
25 |
private static final int PORT = 8080; |
|
26 |
private static final String WEBSITE_APP_URL = "http://localhost"; |
|
27 |
private static String url; |
|
28 |
|
|
29 |
WebDriver driver; |
|
30 |
|
|
31 |
@BeforeAll |
|
32 |
static void setupClass() { |
|
33 |
WebDriverManager.chromedriver().setup(); |
|
34 |
url = WEBSITE_APP_URL + ":" + PORT; |
|
35 |
} |
|
36 |
|
|
37 |
@BeforeEach |
|
38 |
void setupTest() { |
|
39 |
driver = new ChromeDriver(); |
|
40 |
} |
|
41 |
|
|
42 |
@AfterEach |
|
43 |
void teardown() { |
|
44 |
driver.quit(); |
|
45 |
} |
|
46 |
|
|
47 |
@Test |
|
48 |
void testOpenSpadeApplication() { |
|
49 |
// init testing if the driver can open up the browser and the running application in it. |
|
50 |
driver.get(url); |
|
51 |
String title = driver.getTitle(); |
|
52 |
assertThat(title.toLowerCase().contains("spade")); |
|
53 |
} |
|
54 |
|
|
55 |
} |
Také k dispozici: Unified diff
#11 prepared class for UI tests. Only scenarios need to be added.