-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwiki.txt
More file actions
54 lines (36 loc) · 2.67 KB
/
wiki.txt
File metadata and controls
54 lines (36 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
This is a wiki file where problems I have encountered and how I have overcame them.
Problem : I could not run test by mvn -clean test.
Solution : maven-surefire-plugin should be 2.22.0 or higher for Junit-5 needed
Where I found : https://www.petrikainulainen.net/programming/testing/junit-5-tutorial-running-unit-tests-with-maven/
Problem : Setting JAVA_HOME variable
Solution : Go to .zsh_profile and/or .bash_profile and set path as follows (path where u have installed Java) , save the file and restart the terminal
export JAVA_HOME=$(/Library/Java/JavaVirtualMachines/jdk1.8.0_281)
export PATH=$PATH:$JAVA_HOME/bin
Problem : Running test methods in parallel
Solution : Setting properties in junit-platform-properties to have a parallel test
Note : Also this could be achieved in pom.xml file.
Problem : Not able to run tests in parallel when @BeforeEach method is included in org.maksu.BaseTest.class
Solution: Implemented @BeforeEach and @AfterEach methods for all test classes. But this is not a best practice since therw will be huge code multiplication when
new test classes added to project.
Result : @TestInstance(TestInstance.Lifecycle.PER_METHOD) annotaion over BaseTest.class did it! Now all test methods run in parallel.
Hint : You can also define junit config parameters in pom.xml as follows :
https://junit.org/junit5/docs/current/user-guide/#running-tests-build-maven-config-params
Hint : You can get text of an input element by getAttribute("value").
Problem : I needed to read the email for "forgot-password" case.
Soluiton: Created a GmailInbox.class for that purpose
Found : https://www.technicalkeeda.com/java-tutorials/how-to-access-gmail-inbox-using-java-imap
Sub Problem : Parsing mail content
Solution : I used apache-commons-email for parsing emails.
Found : https://stackoverflow.com/questions/11240368/how-to-read-text-inside-body-of-mail-using-javax-mail/31877854#
Problem : How to run junit tagged test classes by maven
Solution: Use mvn clean -Dgroups="abc" test
Found : https://mkyong.com/junit5/junit-5-tagging-and-filtering-tag-examples/
Hint : To run all test classes in same thread but their methods in parallel use this :
junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.mode.default = concurrent
junit.jupiter.execution.parallel.mode.classes.default = same_thread
Problem : How to keep up to date webdriver versions:
Solution: Using WebDriverManager here : https://github.com/bonigarcia/webdrivermanager
You do not need to define anything. It will run...
Important Notes concerning design!
- All tests methods should be independent and run randomly.