i used ExecutorService to manually run TestNG tests in different threads.
testng multiple threads for whole IT class
-
10-06-2023 - |
Вопрос
i have a testng suite with some 2 test methods. createuser() and updateuser(). also i have an instance variable User user; so at end of createUser() i associate the created user to that instance variable user. now in updateUSer() (dependent upon Createuser) i try to update some attributes of this object.
everything runs fine normally. but when i use invocationcount=3, threadpoolsize=3, sometimes some of the methods will fail. now i figured out this is due to 1 common shared User instance for different threads.
is there any way whole IT class with different methods run in 1 single thread but i can spawn multiple executions of this IT. so thread 1 -> IT with 2 tests, thread 2-> IT with 2 tests and so on...
so i am looking something like invocationcount and threadpoolsize for the whole IT class instead of each method.
Решение