|
Re: design issue: msg#00198java.junit.user
--- In junit@xxxx, Boris Garbuzov <boris_garbuzov@xxxx> wrote: > Thanks, J.B., I will follow your practical > recommendation. But still there are 2 theoretical > questions: > 1. How to implement TestListener in a TestCase? More > exactly, how to add it? > 2. What is the difference between setUp() and > startTest()? I'm far from an expert on the matter but... 1. As far as I know TestListeners are merely observers of tests. Usually in order to provide Views on test progress to the tester (of the person class -> end user subclass) so that they can informed of the results. I may be mistaken here but testers do not usually mess with TestListeners inside of a TestCase. In other words, they are interface elements. They follow (or are players in) the Observer Pattern as in the GOF book. http://c2.com/cgi/wiki?ObserverPattern http://c2.com/cgi/wiki?DesignPatternsBook The TestRunner classes are the observers in the standard jUnit framework. They indicate their interest of being notified of test progress/events by registering themselves with a TestResult. If you take a look at the source code inside TestRunner classes you can see how this is done. Those who extend or enhance the framework may add the listeners/observers in a different way but the idea is the same. 2. A tester puts in their code which does whatever is needed to set up a test's fixture in setUp(). Like opening a file, opening a database, or doing any initializations which may be common across all tests in a TestCase. startTest() is just for TestListeners it has nothing to do with a end user's writing of TestCase code. TestListeners are informed that a test has started through this interface. You can see this in the source code of TestResult. However, don't take my word for it as I can't even program in Java. Anthony Adachi
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Re: design issue, J. B. Rainsberger |
|---|---|
| Next by Date: | Re: design issue, Vladimir Bossicard |
| Previous by Thread: | Re: design issue, Vladimir Bossicard |
| Next by Thread: | Multiple Test Cases, Gopinath Ramakrishnan |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |