View Javadoc
1   /*
2    * Copyright 2005 Werner Guttmann
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5    * in compliance with the License. You may obtain a copy of the License at
6    *
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software distributed under the License
10   * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11   * or implied. See the License for the specific language governing permissions and limitations under
12   * the License.
13   */
14  package org.codehaus.castor.maven.xmlctf;
15  
16  import junit.framework.Test;
17  import junit.framework.TestResult;
18  import junit.textui.TestRunner;
19  
20  import org.apache.maven.plugin.MojoExecutionException;
21  import org.apache.maven.plugins.annotations.Mojo;
22  import org.apache.maven.plugins.annotations.ResolutionScope;
23  
24  /**
25   * Uses a simple junit.ui.TestRunner TextRunner to run the XMLCTF test suite.
26   * 
27   * @since 1.2
28   */
29  @Mojo(name = "xmlctf-text", requiresDependencyResolution = ResolutionScope.RUNTIME,
30      requiresProject = true)
31  public class TextTestSuiteMojo extends AbstractTestSuiteMojo {
32  
33    public void runJUnit(Test testSuite) throws MojoExecutionException {
34      TestResult result = TestRunner.run(testSuite);
35  
36      if (result.errorCount() > 0 || result.failureCount() > 0) {
37        throw new MojoExecutionException("Errors or Failures occured testing the MasterTestSuite!");
38      }
39    }
40  
41  }