You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Nicko Cadell <ni...@neoworks.com> on 2005/05/03 00:24:55 UTC

RE: A mock log4net appender

A mock appender sounds like a good idea for our tests. Currently the tests use a combination of different appenders, but mostly the CountingAppender. 
http://cvs.apache.org/viewcvs.cgi/logging-log4net/tests/src/Appender/CountingAppender.cs

To submit your mock appender please use the issue tracking system.
http://issues.apache.org/jira/browse/LOG4NET

Create a new issue for your patch. On the log4net issues home page select the Create New Issue from the menu bar. You will need to be logged into JIRA in order to create an issue.

Select the issue type as appropriate.

Prefix the summary with [PATCH]. Enter a description of the changes made, new features, or bug fixes in your patch.

Once the issue has been created you can attach your patch file to the issue by selecting the Attach file to this issue operation from the left hand menu. When attaching your patch you must select the Grant license to ASF for inclusion in ASF works option. If attaching a patch please include in the description the baseline version of log4net you used to build your patch, if against a CVS version please include the date and branch (e.g. HEAD).

If you have other files to attach, e.g. you have added new files to log4net, then attach each file separately. Please include in the description the name of the file attached and the path it should live in the project.

Cheers,
Nicko

> -----Original Message-----
> From: Thibaut Barrère [mailto:thibaut.barrere@gmail.com] 
> Sent: 27 April 2005 19:29
> To: Log4NET User
> Subject: A mock log4net appender
> 
> Hi,
> 
> I wrote a mock log4net appender to ensure that my unit tests 
> fails when some errors are (sometimes silently) logged 
> through log4net.
> 
> Sample usage in NUnit style:
> 
> [SetUp]
> public void SetUp()
> {
>        DOMConfigurator.Configure();
> 
>        // create a mock log4net appender to verify that no 
> error is outputted
>        mockLog4netAppender = new MockLog4netAppender();
>        // expect zero errors
>        mockLog4netAppender.ExpectErrors(0);
>        mockLog4netAppender.RegisterAppender();
> }
> 
> [TearDown]
> public void TearDown()
> {
>        // verify that no error was outputed by log4net
>        mockLog4netAppender.Verify();
> }
> 
> 
> Current implementation is very basic, and depends upon NMock; 
> it's actually a specialized DynamicMock, so specific 
> expectations can be added in each test when required.
> 
> Is there some interest for including tools of this kind in 
> the log4net distribution (either as a static mock, or a 
> dynamic mock) ? Or is there an already available feature 
> which could provide the same service ?
> 
> 
> best regards
> 
> Thibaut Barrère
> 
> http://www.dotnetguru2.org/tbarrere
> 

Re: A mock log4net appender

Posted by Thibaut Barrère <th...@gmail.com>.
I see two possible uses :
- in log4net test project (adding a nmock dependency is not big deal
there I suppose)
- in log4net itself, for end-users (such as Owen or me). 

Do you want to also target the second option ? We would then have a
dependency on nmock which you may want to avoid. If it's no big deal I
can target the two options at once (I'd add the mock appender inside
the log4net project, and use it in the test project).

cheers

Thibaut

2005/5/3, Nicko Cadell <ni...@neoworks.com>:
> A mock appender sounds like a good idea for our tests. Currently the tests use a combination of different appenders, but mostly the CountingAppender.
> http://cvs.apache.org/viewcvs.cgi/logging-log4net/tests/src/Appender/CountingAppender.cs
> 
> To submit your mock appender please use the issue tracking system.
> http://issues.apache.org/jira/browse/LOG4NET
> 
> Create a new issue for your patch. On the log4net issues home page select the Create New Issue from the menu bar. You will need to be logged into JIRA in order to create an issue.
> 
> Select the issue type as appropriate.
> 
> Prefix the summary with [PATCH]. Enter a description of the changes made, new features, or bug fixes in your patch.
> 
> Once the issue has been created you can attach your patch file to the issue by selecting the Attach file to this issue operation from the left hand menu. When attaching your patch you must select the Grant license to ASF for inclusion in ASF works option. If attaching a patch please include in the description the baseline version of log4net you used to build your patch, if against a CVS version please include the date and branch (e.g. HEAD).
> 
> If you have other files to attach, e.g. you have added new files to log4net, then attach each file separately. Please include in the description the name of the file attached and the path it should live in the project.
> 
> Cheers,
> Nicko
> 
> > -----Original Message-----
> > From: Thibaut Barrère [mailto:thibaut.barrere@gmail.com]
> > Sent: 27 April 2005 19:29
> > To: Log4NET User
> > Subject: A mock log4net appender
> >
> > Hi,
> >
> > I wrote a mock log4net appender to ensure that my unit tests
> > fails when some errors are (sometimes silently) logged
> > through log4net.
> >
> > Sample usage in NUnit style:
> >
> > [SetUp]
> > public void SetUp()
> > {
> >        DOMConfigurator.Configure();
> >
> >        // create a mock log4net appender to verify that no
> > error is outputted
> >        mockLog4netAppender = new MockLog4netAppender();
> >        // expect zero errors
> >        mockLog4netAppender.ExpectErrors(0);
> >        mockLog4netAppender.RegisterAppender();
> > }
> >
> > [TearDown]
> > public void TearDown()
> > {
> >        // verify that no error was outputed by log4net
> >        mockLog4netAppender.Verify();
> > }
> >
> >
> > Current implementation is very basic, and depends upon NMock;
> > it's actually a specialized DynamicMock, so specific
> > expectations can be added in each test when required.
> >
> > Is there some interest for including tools of this kind in
> > the log4net distribution (either as a static mock, or a
> > dynamic mock) ? Or is there an already available feature
> > which could provide the same service ?
> >
> >
> > best regards
> >
> > Thibaut Barrère
> >
> > http://www.dotnetguru2.org/tbarrere
> >
>