View Javadoc
1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.ant;
5   
6   import org.apache.tools.ant.BuildFileTest;
7   import org.junit.Test;
8   
9   public class PMDTaskTest extends BuildFileTest {
10  
11      @Override
12      protected void setUp() throws Exception {
13          super.setUp();
14          configureProject("src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml");
15      }
16  
17      @Test
18      public void testFormatterWithNoToFileAttribute() {
19          expectBuildExceptionContaining("testFormatterWithNoToFileAttribute", "Valid Error Message", "toFile or toConsole needs to be specified in Formatter");
20      }
21  
22      @Test
23      public void testNoRuleSets() {
24          expectBuildExceptionContaining("testNoRuleSets", "Valid Error Message", "No rulesets specified");
25      }
26  
27      @Test
28      public void testBasic() {
29          executeTarget("testBasic");
30      }
31  
32      @Test
33      public void testInvalidLanguageVersion() {
34          expectBuildExceptionContaining("testInvalidLanguageVersion", "Fail requested.", "The following language is not supported:<sourceLanguage name=\"java\" version=\"42\" />.");
35      }
36  }