Can I have two @Test Annotations in a single class? | TestNG interview question | Automation Testing

Can I have two @Test Annotations in a single class? | TestNG interview question | Automation Testing

SoftwaretestingbyMKT

1 год назад

10,108 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@akshatapatil283
@akshatapatil283 - 11.04.2023 12:09

Yes we can have 2 @ test in a single class
1] Based on priority
If priority not given
Method name with alphabet priority
Ex: method name abc() &xyz()
abc() get executed 1st

Ответить
@IT_Spiders
@IT_Spiders - 24.11.2023 15:44

Yes it is possible to have 2 @test in the same class.
Order of execution will be as follows like this;
@BeforeSuite
@BeforeTest
@BeforeClass
@BeforeMethod
@Test
@AfterMethod
@beforeMethod
@Test
@AfterMethod
@AfterClass
@AfterTest
@AfterSuite

Ответить
@satyasai2835
@satyasai2835 - 23.11.2023 12:07

It will follow ASCII order.

Ответить
@meghanasugandachar5851
@meghanasugandachar5851 - 19.11.2023 16:34

Yes we can. The order will be alphabetical order by default
If we want the order to be changed then we should set the priority

Ответить
@anirudhchristine7423
@anirudhchristine7423 - 27.10.2023 11:59

First before methods after @test1 and after again before methods, and after method it will executing

Ответить
@bhaktisongs3146
@bhaktisongs3146 - 21.10.2023 12:42

Yez we can have 2@ testin single class it is executed based on priority if priority isnot given then executed by alphabetical order

Ответить
@user-mj7nx1bz5q
@user-mj7nx1bz5q - 16.10.2023 18:49

yes

Ответить
@Vinay.vijaya.Vlogs5
@Vinay.vijaya.Vlogs5 - 16.10.2023 15:31

Yea we can have 2 @test in a single class 1.based on priority if priority not given
2.Method was taken alphabet order

Ответить
@shanthipriya7871
@shanthipriya7871 - 19.09.2023 06:52

While developing a framework can one use junit and testng assertions in a single class? Have a doubt. Thanks.

Ответить
@bharatkysaram6733
@bharatkysaram6733 - 15.09.2023 08:38

Yes we can have two tests and execute bases on alphabetical order

Ответить
@vineetvinu422
@vineetvinu422 - 14.09.2023 16:10

yes in a single class it is possible If priority is not given then on this basis of alphanumeric 2@ test case method get executed... .. For example method name def() fgh() , def() get first executed.

Ответить
@user-sb6du6yr3o
@user-sb6du6yr3o - 27.08.2023 05:57

yes and if we Don't provide priority then order of execution based on Alphabetical manner

Ответить
@akshaybhalme9475
@akshaybhalme9475 - 19.08.2023 20:02

According to priority we can execute two @test keywords

Ответить
@udhayasankar702
@udhayasankar702 - 25.07.2023 13:36

ASCII ORDER

Ответить
@sridevisarath-bk5ij
@sridevisarath-bk5ij - 14.07.2023 20:10

Yes we can create more tests. While execution depends on priority otherwise it will execute in alphabetical order

Ответить
@jenishkaruniyad1578
@jenishkaruniyad1578 - 08.07.2023 04:29

yes, @test(priority=0)
@test(priority=1)

Ответить
@ashishkumarswain7931
@ashishkumarswain7931 - 06.06.2023 08:01

Yes we can use multiple @Test in a class but it will execute in alphabetical order and. If you provide a priority flag it will execute in your priority order.

Ответить
@Anandramit
@Anandramit - 27.05.2023 22:19

Random

Ответить
@anandm1292
@anandm1292 - 27.04.2023 20:20

If we don't mention priority, it will execute in alphabetical order

Ответить
@sv1178
@sv1178 - 18.04.2023 11:38

Yes, we can have more than 2 @Test in a Class.
These are executed in Method name alphabetical order.
Or we can set the execution by @Priority

Ответить
@Achyuthkumar-ie6vg
@Achyuthkumar-ie6vg - 17.04.2023 20:56

Yes. if priority is not given then alphabetical order it is Executed.

Ответить
@vbn120
@vbn120 - 14.04.2023 13:51

Also based on Alphabet it will be executed. Suppose method a() and z().

Then a() will be executed first

Ответить
@peterdaruwala5568
@peterdaruwala5568 - 12.04.2023 22:28

Yes executed as per ascii value

Ответить
@ritikanagpal634
@ritikanagpal634 - 12.04.2023 20:22

Yes we can have 2 annotations and executes as per the priority

Ответить
@psrathod
@psrathod - 12.04.2023 08:32

Yes. If u give them priority then those test cases run as the way of what is the priority, if u don't give them priority then they will run alphabet wise.

Ответить
@ramakrishnapenumudi1024
@ramakrishnapenumudi1024 - 12.04.2023 05:43

Yes 🤚

Ответить
@mubasheeruddiinkhaja7025
@mubasheeruddiinkhaja7025 - 12.04.2023 03:53

Yes

Ответить
@ksowmya9586
@ksowmya9586 - 11.04.2023 19:06

Yes.we can have two @Test Annotations in a single class.If we give priority,it will execute according to the priority.Otherwise it will execute in Alphabetical order of TestCase names.

Ответить
@vaibhavkumbhar8309
@vaibhavkumbhar8309 - 11.04.2023 17:42

Yes possible, if priority is given then according to priority they will execute
Otherwise they will executed according to alphabetical order of method names

Ответить
@PJYTJ
@PJYTJ - 11.04.2023 16:01

Yes,it will be executed in alphabetical order 🥳 or executed in priority wise if we set any priority 😊

Ответить
@shwetakumari203
@shwetakumari203 - 11.04.2023 14:43

Yes , it is possible . And execution depending on the priority. For every @Test have it's own@BeforeMethod and @ AfterMethod

Ответить
@aaradhyasvlog5356
@aaradhyasvlog5356 - 11.04.2023 14:37

Yes alphabetically they will get executed

Ответить
@prathameshloke1114
@prathameshloke1114 - 11.04.2023 13:32

Yes

Ответить
@sujitblues
@sujitblues - 11.04.2023 13:28

Yes, it's possible to have two @Test Annotation in single class .it will run according to the priority if priority is there or it will run according alphabetical order of methods if priority is not there

Ответить
@sivaram4563
@sivaram4563 - 11.04.2023 13:15

Based on alphabetical order

Ответить
@saurabhchavan863
@saurabhchavan863 - 11.04.2023 13:11

Yes it is possible and order of execution will be depends on alphabetical order

Ответить
@snehalkhobragade8290
@snehalkhobragade8290 - 11.04.2023 13:05

yes, will execute in alphabetical order

Ответить
@shayistatarannum1897
@shayistatarannum1897 - 11.04.2023 12:49

In single test case we can have multiple @ test.
Execution depends on priority of the @test if given.
If the priority is not mentioned then it depends on the alphabetical order of the method name.
For Ex: method1 public void abc() and method2 Public void bac()
Public void abc will get executed first.

Ответить
@priyankavastre3788
@priyankavastre3788 - 11.04.2023 12:35

Yes, We can have .

Ответить
@nirajnagwekar7772
@nirajnagwekar7772 - 11.04.2023 12:29

Yes we can have 2 or more @Test in single class
Execution will be done depending on either priority given to Test or respective to Alphabetical order with reference to Test Name (method name)

Ответить