Raymond DeCampo wrote:
> Andrew McDonagh wrote:
>
>> wrote:
>>
>>> Is there a more dynamic way of setting up tests? We have legacy test
>>> code that we are trying to convert to junit.
>>>
>>> I think it is silly to be required to set up a "testFunc(...)" method
>>> for each test.
>>>
>>> We'd prefer:
>>>
>>> abstract void runTests(Results x);
>>>
>>> In your code you implement that and populate Results. If the runTests
>>> blows up, the caller catches the exception and populates TestsResults
>>> on the methods behalf. Easy, breezy, and would have worked just fine
>>> with Java 1.18.
>>>
>>> Right now we just have runAllTests, but that makes the junit report too
>>> boring, we want to see each test. It will be too tedious to make a
>>> separate method for each test.
>>>
>>
>> it would be better to post this message to the JUnit yahoo group where
>> there is a huge wealth of experience and help available to you.
>>
>>
>> As it is, what you are asking for is either:
>>
>> 1) Parametrized TestCase - (Google-able)
>> - If you are testing the same functionality with different data
>>
>> or
>>
>> 2) Not Applicable to JUnit
>> - If you are trying to test multiple functionalities with one
>> method. As each test case (the test method) is supposed be decriptive
>> of the functionality its testing and so lumping everything into one
>> big 'testTheWorld(stuff)' defeats that.
>>
>
> I hate that "not applicable to JUnit" crap. (No offense Andrew.)
None taken
I was merely trying to point out that JUnit isn't designed for that
scenario (in fact I think the OP has seen this by the remark that the
'test failure message was boring'). But you are right, a custom
TestRunner might be able to do what the OP wants.
> It
> just bothers me that people try to push you into using the tool only one
> way. What if I want an automated integration test? JUnit is able to do
> this, even if it goes against the philosophy of its creator.
>
Sure any of the xUnit frameworks can be used for integration, System,
UAT, SAT, etc tests - it usually comes down to how the test is described
that makes one tool more appropriate than another.
Personally, I would use any of the xUnit frameworks for any testing
other that unit testing. The other tests will (in my situation) has to
be readable by my customers - they don't know Java. But they can read
something like....
Start IE
Browse to
http://www.google.com
Enter 'Watir' into searchBox
Click Search button
Check Page contains 'Watir: Web Application Testing in Ruby'
Now in JUnit this test would not be anywhere near as short nor readable
to a non-programmer (be they Customer or tester).
Its Horses-for-courses rather than 'that-aint-what-I-created-it-for'
Andrew
> This is especially true when you've inherited an "engine" that doesn't
> already have unit tests. You only really care about the external
> interface; you do not have time to reverse engineer every class to
> create unit tests.
Agreed, in fact I'd recommend that we don't retrofit unit tests. I
would add a few integration/acceptance tests if possible, using a DSL
something like above.
> Automated integration tests based on the macro,
> known desired behavior of the system is useful here.
>
> The OP might want to look into creating a custom TestRunner.
>
> Ray
>