any integration of JUnit and Log4J?

Discussion in 'Java' started by nospawn, Feb 3, 2006.

  1. nospawn

    nospawn Guest

    Hi all,

    I want to provide Test Cases for a validation and handling process.
    The validation classes are just part of a chain process where if
    the validation passes then it continues to the next "successor"
    in the chain (of Responsibility -GoF) otherwise the validator stops
    the process and does not forward the call but uses logging to file
    the problem.

    The only outcome of the validation classes is to:

    - Write the issue into log.fatal(...) and does not forward the call.
    - Forwards the call to the next successor.

    Now I have two options to test the validation classes:

    1-. Have the original class write some flags somewhere about the
    outcome (nasty and original code intrusive solution).

    2-. Have some logging scan facility .... is there any kind of
    integration between Log4J and JUnit to achieve this?

    TIA,
    Best Regards,
    Giovanni
    nospawn, Feb 3, 2006
    #1
    1. Advertising

  2. nospawn

    James Westby Guest

    nospawn wrote:
    > Hi all,
    >
    > I want to provide Test Cases for a validation and handling process.
    > The validation classes are just part of a chain process where if
    > the validation passes then it continues to the next "successor"
    > in the chain (of Responsibility -GoF) otherwise the validator stops
    > the process and does not forward the call but uses logging to file
    > the problem.
    >
    > The only outcome of the validation classes is to:
    >
    > - Write the issue into log.fatal(...) and does not forward the call.
    > - Forwards the call to the next successor.
    >
    > Now I have two options to test the validation classes:
    >
    > 1-. Have the original class write some flags somewhere about the
    > outcome (nasty and original code intrusive solution).
    >
    > 2-. Have some logging scan facility .... is there any kind of
    > integration between Log4J and JUnit to achieve this?
    >


    Could you write a custom logger that makes a callback to the junit test
    case with any logged messages, allowing you to determine if anything
    happened? As for success it sounds like mock objects might help. Come to
    think of it a mock logger might work quite nicely as well.


    James
    James Westby, Feb 3, 2006
    #2
    1. Advertising

  3. Hi James,

    Many thanks for your response!

    "James Westby" <> wrote:
    > Could you write a custom logger that makes a callback to the junit test
    > case with any logged messages, allowing you to determine if anything
    > happened? As for success it sounds like mock objects might help. Come to
    > think of it a mock logger might work quite nicely as well.
    >

    That is a great idea :)

    But trying could not setup a custom Appender or even Logger actually
    Appender is better for me because my Test class already inherits from
    TestCase so I had it implement Appender ... it does not work ... any
    hints as to where find an example?

    Many thanks!
    Best Regards,
    Giovanni
    Giovanni Azua, Feb 3, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alexandra Stehman

    eclipse, junit, log4j, & finding log4j.xml

    Alexandra Stehman, Jan 19, 2004, in forum: Java
    Replies:
    0
    Views:
    5,744
    Alexandra Stehman
    Jan 19, 2004
  2. bugbear
    Replies:
    4
    Views:
    1,809
    bugbear
    Jan 28, 2004
  3. Paul Carey

    Log4j and JUnit conflict

    Paul Carey, May 21, 2004, in forum: Java
    Replies:
    0
    Views:
    1,182
    Paul Carey
    May 21, 2004
  4. Alex Hunsley
    Replies:
    2
    Views:
    12,899
    =?ISO-8859-15?Q?Fr=E9d=E9ric_G=E9din?=
    May 28, 2004
  5. BlueDolphin

    log4j and console in ANT/JUnit task

    BlueDolphin, Oct 21, 2004, in forum: Java
    Replies:
    6
    Views:
    10,149
    BlueDolphin
    Oct 23, 2004
Loading...

Share This Page