Implemented[1][2][3][4] and documented here:
http://dev.xwiki.org/xwiki/bin/view/Community/Testing#HJavaUnitTesting

From now it’s forbidden to add excludes to project’s pom.xml :) Instead we 
should work to remove all the following I add to poms for projects having tests 
outputting stuff to the console:

      <!-- TODO: Remove once the tests have been fixed to not output anything 
to the console! -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <properties combine.self="override"/>
        </configuration>
      </plugin>

Thanks
-Vincent

[1] http://jira.xwiki.org/browse/XCOMMONS-738
[2] http://jira.xwiki.org/browse/XCOMMONS-739
[3] http://jira.xwiki.org/browse/XRENDERING-380
[4] http://jira.xwiki.org/browse/XWIKI-11745

On 2 Feb 2015 at 15:02:30, Guillaume Louis-Marie Delhumeau 
([email protected](mailto:[email protected])) wrote:

> +1
>  
> 2015-02-02 14:12 GMT+01:00 Thomas Mortagne :
>  
> > +1
> >
> > On Mon, Feb 2, 2015 at 10:45 AM, [email protected]  
> > wrote:
> > > Hi devs,
> > >
> > > I don’t recall if we had already agreed to this proposal or not so now
> > that I’ve progressed with its implementation I’m sending this mail to
> > ensure we all agree.
> > >
> > > Rationale:
> > >
> > > * The build logs should not be polluted with “normal” stack traces, or
> > any message. Anything that the test produces should be contained and
> > asserted in the test itself.
> > > * If some logs go through it means they’ve not been captured and not
> > been asserted in the test.
> > > * It makes the test writer more aware of what the code being tested
> > outputs and thus what the test writer needs to do about these.
> > >
> > > Implementation details:
> > >
> > > * Fail the build if some unit test output content to stdout or stderr.
> > > * By default any code that outputs log will send content to stdout
> > (since by default slf4j/logback will use a Console Appender that logs to
> > stdout).
> > > * Thus when code output logs, the test need to capture those logs. I’m
> > introduced a new rule (@AllLogRule - see
> > https://gist.github.com/vmassol/d6357901fca25db74783) which captures all
> > logs.
> > > * The @AllLogRule rule will fail the test if the captured logs are not
> > asserted (it can be asserted for its content or the test can explicitly say
> > it doesn’t care about it).
> > > * There will be a custom RunListener (CaptureConsoleRunListener - see
> > https://gist.github.com/vmassol/f3b7496b5bd3a9693fc2) plugged into the
> > Maven Surefire plugin that fails the build if there’s content sent to
> > stdut/stderr
> > > * Our Maven build will perform the check by default and we’ll start by
> > disabling it in the modules that currently fail.
> > > * The idea is that slowly over time we remove the disabling in those
> > modules as we fix the tests and that for new modules we apply the new rule
> > (which will be enabled by default)
> > >
> > > Example of capturing/asserting logs:
> > >
> > > @Rule
> > > public AllLogRule logRule = new AllLogRule();
> > > …
> > > assertEquals("Error getting resource [bad resource] because of
> > invalid path format. Reason: [invalid url]",
> > > this.logRule.getMessage(0));
> > >
> > > Example of ignoring a log:
> > >
> > > …
> > > assertNotNull(this.logRule.getMessage(0));
> > >
> > >
> > > WDTY?
> > >
> > > Thanks
> > > -Vincent
> > >
> > >
> > > _______________________________________________
> > > devs mailing list
> > > [email protected]
> > > http://lists.xwiki.org/mailman/listinfo/devs
> >
> >
> >
> > --
> > Thomas Mortagne
> > _______________________________________________
> > devs mailing list
> > [email protected]
> > http://lists.xwiki.org/mailman/listinfo/devs
> >
>  
>  
>  
> --
> Guillaume Delhumeau ([email protected])
> Research & Development Engineer at XWiki SAS
> Committer on the XWiki.org project
> _______________________________________________
> devs mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to