• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Next Generation Java Testing book

 
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Cedric and Hani,
Welcome to Javaranch. I am using google web toolkit with RPC calls to database. Your book index has Asynchronous Testing topic. Do you think it will help me testing RPC calls to database?

Thanks
 
author
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it's actually very easy to do this sort of test via dependencies, we cover this quite extensively in the book (both in terms of async testing in general, and illustrating the same techniques later on with JMS).

The basic idea is to have test pairs, one for sending and one for receiving. The receiver depends on the sender, and has a timeout value so you dont end up blocking forever. In code, the test's annotation looks like @Test(dependsOnMethod="sendRequest", timeout=1000)

TestNG will run the first test (or configuration method, if its not an actual test) which will send the request. Then the second test is run, which will read the response (well, wait for it first), and verify the results. TestNG allows you to guarantee that the tests are run in that order, so you dont end up waiting for a response before you've sent the request out.
 
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is interesting. Is there also a way to run two test methods simultaneously? For example, if one wishes to test the server-side and client-side code of a protocol implementation.

Daniel
 
Ken Boyd
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply. I feel pretty good that your book cover async topic. I would definitely look into that in coming weeks as code is growing fast.

Thanks,
Ken
 
author
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Daniel Trebbien:
This is interesting. Is there also a way to run two test methods simultaneously? For example, if one wishes to test the server-side and client-side code of a protocol implementation.

Daniel



Yes: you can ask TestNG to run all your test methods in different threads (you configure the thread pool size in testng.xml). Here is the relevant documentation link:

http://testng.org/doc/documentation-main.html#parallel-running

However, I'm not sure I would do that in the situation you are describing, since both sides should be part of the same test method. You would probably be better off spawning the back-end part in a separate thread and wait for it in the main thread. You can also ask TestNG to abort you after a little while to make sure you won't block:

@Test(timeOut = 5000 /* 5 seconds */)
public void verifyProtocol() {
// ...
}

--
Cedric
 
God is a comedian playing for an audience that is afraid to laugh - Voltair. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic