This discussion is archived
1 2 Previous Next 25 Replies Latest reply: Oct 23, 2008 8:31 AM by 807589 Go to original post RSS
  • 15. Re: Handlers in JUnit tests?
    807589 Newbie
    Currently Being Moderated
    yawmark and George, I'm really disappointed.

    For me there are 2 options, either you don't know the solution to the OPs questions and like to make big words about claiming to know them ...
    OR: you have no clue at all.

    Did you understand his question? Let me rephrase, he somehow likes to "hook" some kind of listener into the JUnit framework, you follow so far? Yes? And? How do you do that?

    You claim you gave plenty of hints how to do it and then you concluded the OP is a moron because he does not understand your hints. Great attitude.

    Did you look at the link you provided? (http://junit.sourceforge.net/javadoc/org/junit/runner/notification/RunListener.html) ... did you see the code fragment:
     public void main(String... args) {
        JUnitCore core= new JUnitCore();
        core.addListener(new RingingListener());
        core.run(MyTestClass.class);
     }
    Do you know it does not work if you like to run a Test (Suite) as a JUnit Test with right mouse form Eclipse? Do you know it does not work if you try to use ant and the ant-junit task to start your tests?

    Do you know it? Or don't you know it?

    The explanations how JUnit is working, how to use the annotations correctly and when to subclass what is mediocre, at best.

    Even real heros like Alex Ruiz have big trouble to understand how to register Runners correctly. (I worked like 14 days on figuring and gave up. A friend finally found out how to do it)

    So, my point is only:
    Either you understood what the OP is asking for, then your claim: "you got excellent points where to continue" is just bullshit, because you gave none.
    Or you did not understand at all what his problem is, then your claim: "you got excellent points where to continue" is just bullshit either! Because if you don't understand what his problem is, please don't point him to web sites he very likely has read already.

    @Jrm

    Sorry that you ran in such strange attituded people here. If you still have problems, I post a code example (for some weird reasons I finally managed to get such a thing running just today ... after 14 days of googeling, searching, debugging JUnit core classes. Bottom line it is so easy that no one seems to find words explaining how to do it ...)

    Best Regards,

    Angelo / muhhuhuhuhua needed to make this second account because Suns site is unable to recover my password for my real account :-/
  • 16. Re: Handlers in JUnit tests?
    807589 Newbie
    Currently Being Moderated
    aos-the-tard wrote:
    yawmark and George, I'm really disappointed.
    Oh no! How will I sleep, knowing that Johnny Nobody is disappointed in me?
    For me there are 2 options, either you don't know the solution to the OPs questions and like to make big words about claiming to know them ...
    OR: you have no clue at all.
    Nah, secret option #3: the OP is trying to over-complicate matters by missing out on something fundamental
    Did you understand his question? Let me rephrase, he somehow likes to "hook" some kind of listener into the JUnit framework, you follow so far? Yes? And? How do you do that?
    When asked the reason why he wanted to do that, his response was that he wanted to achieve something that the framework already actually provides, if you can be bothered to read the thread properly rather than look for reasons to pick fights
    You claim you gave plenty of hints how to do it and then you concluded the OP is a moron because he does not understand your hints. Great attitude.
    Where did anyone say that? I gave him some advice, and he decided it was time to flame me. Read again. I see nobody calling anyone names. All I see is some people trying to help the OP avoid unnecessary work, and getting a mouthful of abuse for their troubles. Increasingly common behaviour on this forum, as is your nonsensical berating of us long after the fact. Your disappointment is misplaced, you should be disappointed in your own inability to read properly
    Did you look at the link you provided? (http://junit.sourceforge.net/javadoc/org/junit/runner/notification/RunListener.html) ... did you see the code fragment:
    Does he need to do that in order to find out how many tests passed or failed? Really? Because that's what he's trying to achieve.
    Do you know it does not work if you like to run a Test (Suite) as a JUnit Test with right mouse form Eclipse? Do you know it does not work if you try to use ant and the ant-junit task to start your tests?

    Do you know it? Or don't you know it?

    The explanations how JUnit is working, how to use the annotations correctly and when to subclass what is mediocre, at best.

    Even real heros like Alex Ruiz have big trouble to understand how to register Runners correctly. (I worked like 14 days on figuring and gave up. A friend finally found out how to do it)

    So, my point is only:
    Either you understood what the OP is asking for, then your claim: "you got excellent points where to continue" is just bullshit, because you gave none.
    Er, yes we did. The JUnit framework itself provides, out-of-the-box, exactly what the OP is trying to achieve on his own
    Or you did not understand at all what his problem is, then your claim: "you got excellent points where to continue" is just bullshit either! Because if you don't understand what his problem is, please don't point him to web sites he very likely has read already.
    And please don't resurrect old threads simply to start a flamewar based purely on your inability to see beyond your petty indignation
    @Jrm

    Sorry that you ran in such strange attituded people here. If you still have problems, I post a code example (for some weird reasons I finally managed to get such a thing running just today ... after 14 days of googeling, searching, debugging JUnit core classes. Bottom line it is so easy that no one seems to find words explaining how to do it ...)
    Yeh, what a bunch of idiots we are for pointing the OP in the right direction rather than helping him continue to do re-invent the wheel in a complex way. Thanks for picking us up on it!
  • 17. Re: Handlers in JUnit tests?
    807589 Newbie
    Currently Being Moderated
    aos-the-tard wrote:
    Did you look at the link you provided?
    Did you take a moment to realize that neither georgemc nor I posted a link to RunListener (which you then proceeded to rant at length about)? That was posted by "RoyGrini".
    Do you know it? Or don't you know it?
    Do you realize you're completely off-target with your rant? Or don't you?
    So, my point is only:
    Best find a better point. Good luck with that.
    Bottom line it is so easy that no one seems to find words explaining how to do it ...)
    Perhaps there's a good explanation why you chose to flail about with a rambling rant instead of just attempting to help the OP with your exceedingly simple solution.

    ~
  • 18. Re: Handlers in JUnit tests?
    807589 Newbie
    Currently Being Moderated
    Well,

    you both gaev complete helpless "informations" like the not useful ant task. Finally you started unpolite talk towards the original asker ... sorry for my hard words.

    I post an example how to achieve the registration of handlers later. My current "research toy" is a bit to big to just post it here.

    Regards
  • 19. Re: Handlers in JUnit tests?
    807589 Newbie
    Currently Being Moderated
    aos-the-tard wrote:
    you both gaev complete helpless "informations" like the not useful ant task.
    You have made it clear that this is your opinion, but you've offered no explanation as to why you think the information is "helpless". On the contrary, the report provided by the Ant task provides exactly the information the OP was asking for, specifically "the total number of tests and the set of tests which failed". If the OP wants different information, the OP is free to clarify, but it is completely inappropriate for you to jump in with both feet to post some off-target rant.
    Finally you started unpolite talk towards the original asker
    There was nothing impolite about anything I said.
    ... sorry for my hard words.
    It's always a good idea to think before you post.

    Cheers.

    ~
  • 20. Re: Handlers in JUnit tests?
    807589 Newbie
    Currently Being Moderated
    aos-the-tard wrote:
    Well,

    you both gaev complete helpless "informations" like the not useful ant task. Finally you started unpolite talk towards the original asker ... sorry for my hard words.
    Not useful? Why is it not useful? It does what the OP wants. The problem you've hit is a classic one: you're helping the OP to continue working on his proposed solution to a problem, rather than actually helping him with the problem itself. Of course, the other problem you've hit is that your attitude is very poor, and you're more interested in "defeating" other posters than actually achieving anything positive
    I post an example how to achieve the registration of handlers later. My current "research toy" is a bit to big to just post it here.
    Point is, he doesn't need to add a handler. If you were on an automotive forum, and someone was asking for help with a great new machine he was building for his car, to allow it to change direction whilst moving, would you

    a) Help him build his machine
    b) Tell him about steering wheels

    ?
  • 21. Re: Handlers in JUnit tests?
    807589 Newbie
    Currently Being Moderated
    Why don't you reread his posts?

    He specifically asked (even the title of the thread indicates it) how to add handlers to a JUnit test suit. Obviously he needs to run his own "information" gathering and he is not looking for a pre configured ant task.

    The OP told you more or less that he did not find your advices helpful. And some of you started then with sentences like "the learn how to ask more precisely". In fact his question is very clear: +how do I add handlers, how do I gather my own informations during running tests. E.G. like the infos above.+

    Following your analogy,of course I would not tell him about steering wheels, after all you can safely assume he already knows about them ...

    Point is: he might not need a handler, nevertheless he likes to know how to use one. And he made that point perfectly clear imho. After he made it clear you two guys started attacking him ;D

    Anyway, this is how you would do it:
    @RunAs(Suite.class)
     @Suite.SuiteClasses(value={
        my.package.TestClass.class,
    })
    class AllTests { // empty class, it only serves as point for the annotations above
    }
    This above is the normal way under jUnit 4.x for defining a suit which can be started via the context menu in Eclipse or from an Ant task.

    What we now need to do is to define our own TestSuit class.
    public class MyTestSuite extends Suite {
         MyRunListener runListener = new MyRunListener(); // extends org.junit.runner.notification.RunListener
         
         // constructors ommited ...
    
    /**
     * This is the magic point, we need to override run()
     */
        @Override
        public void run (RunNotifier runNotifier) {
            runNotifier.addListener(runListener); // register your listener
    
            // call super.run() ... otherwise we kill the normal running of tests
            super.run(runNotifier);
    
            // remove the listener (otherwise you might end up in adding similar
            // listeners to the same RunNotifier object all the time (not sure about this though)        
            runNotifier.removeListener(runListener); 
        }
    }
    The implementation of your own RunListner is straight forward. Note: the arguments to the methods, e.g. Failure and Description (Failure contains a Description).

    Now you can use your own "Suite" like this:
    @RunAs(MyTestSuite.class) // instead of instructing the Framework to use the standard Suite we use our own suite
     @Suite.SuiteClasses(value={
        my.package.TestClass.class,
    })
    class AllTestsNEW { // empty class, it only serves as point for the annotations above
    }
    The MyTestSuite class is used via the annotation. So this process works for ant based starting of your "AllTestsNEW" class as well as for starting it manually via the context menu.

    Have fun
  • 22. Re: Handlers in JUnit tests?
    807589 Newbie
    Currently Being Moderated
    aos-the-tard wrote:
    Why don't you reread his posts?

    He specifically asked (even the title of the thread indicates it) how to add handlers to a JUnit test suit. Obviously he needs to run his own "information" gathering and he is not looking for a pre configured ant task.
    That's not obvious at all, I'm afraid. It's more likely that the OP simply thought he wasn't getting help, as no code was forthcoming. That's the most common pattern here. A huge majority of the questions asked here are by people who are trying unnecessarily complex solutions to problems for which a simpler solution already exists. That you don't yet understand that is no reason to go picking fights
    The OP told you more or less that he did not find your advices helpful. And some of you started then with sentences like "the learn how to ask more precisely". In fact his question is very clear: +how do I add handlers, how do I gather my own informations during running tests. E.G. like the infos above.+

    Following your analogy,of course I would not tell him about steering wheels, after all you can safely assume he already knows about them ...
    Then you clearly have never seen anyone overlook the obvious. That doesn't mean it doesn't happen
    Point is: he might not need a handler, nevertheless he likes to know how to use one. And he made that point perfectly clear imho. After he made it clear you two guys started attacking him ;D
    Attacking! Grow a skin.

    The End. You're clearly only looking to "win" a "fight". I'm not indulging you any further. Feel free to infer whatever pointless victories or "Ho ho! What a loser!" nonsense you wish. I've seen it all before

    edit: you "win". I'm out. I no longer wish to contribute to this never-ending series of pointless arguments. It's unrewarding and frustrating, not worth the effort for the occasional "thanks"

    Edited by: georgemc on Oct 15, 2008 3:07 PM
  • 23. Re: Handlers in JUnit tests?
    807589 Newbie
    Currently Being Moderated
    Hi,

    I just saw the new postings. The initial solutions provided indeed helps counting tests, but I need to accomplish more. I need to extract more sophisticated information from my tests. I don't see how I can escape using handlers.

    Aos-the-tard, thanks for sharing your code, I'll take a look at this.

    Cheers,

    J.
  • 24. Re: Handlers in JUnit tests?
    mlk Newbie
    Currently Being Moderated
    Jrm wrote:
    Hi,

    I just saw the new postings. The initial solutions provided indeed helps counting tests, but I need to accomplish more. I need to extract more sophisticated information from my tests. I don't see how I can escape using handlers.
    What information do you require?
  • 25. Re: Handlers in JUnit tests?
    807589 Newbie
    Currently Being Moderated
    Hi mlk,

    I need general statistical information about number of successful/unsuccessful tests etc..., but I also need to know the rate of achieved tests per seconds or minutes. By that, I don't mean the total time / number of tests which is only available when all the tests have been ran. What I need is the number of tests achieved per seconds or minutes, each second and each minute. This varies for each test runs.

    In addition, I am interested in knowing about failed tests early so one can start working on these while the other tests are still running. This can be very interesting when one is running thousands of tests on a system. It saves time.

    Cheers,

    J.
1 2 Previous Next