java - TestNG Make assert in multithread way (not run in multithread) -


my problem need call method in multithread way, such

@test public void assigninmutithread() {     thread thread1 = new thread(new assignandexpect(0));     thread1.start();     thread thread2 = new thread(new assignandexpect(1));     thread2.start();     thread1.join();     thread2.join(); } 

thread send http request , check if response equals expect. need override public void run() method, can not return response code test method.

public class assignexecuteandassert implements runnable{      int expectedassert = 0;      public assignexecuteandassert(int expectedassert)     {         this.expectedassert = expectedassert;     }      public void run() {         httpget assign1 = new httpget("http://localhost:8707/assign?uuid="+(new random().nextint(99999)));         httpclient httpclient = new defaulthttpclient();         httpresponse response = httpclient.execute(assign1);         inputstream inputstream = response.getentity().getcontent();         int resoponsestatus = inputstream.read();         assert.assertequals(resoponsestatus, expectedassert);     } } 

and problem whatever assert right or wrong, test method passed. there way make test fail if assert in thread fail?

i find similar question here: failing testng unit test callback don't own in code there no answer.

and suggestion appreciated.

thanks!

you can try suggestion in this post.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -