View Javadoc
1   package com.simpligility.maven.plugins.android.standalonemojos;
2   
3   import com.simpligility.maven.plugins.android.*;
4   
5   import io.takari.maven.testing.TestResources;
6   import io.takari.maven.testing.executor.MavenExecutionResult;
7   import io.takari.maven.testing.executor.MavenRuntime;
8   import io.takari.maven.testing.executor.MavenVersions;
9   import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner;
10  
11  import org.junit.Rule;
12  import org.junit.Test;
13  import org.junit.runner.RunWith;
14  
15  import java.io.File;
16  
17  /**
18   * Test the lint mojo. Tests options' default values and parsing. Tests the parameters passed to lint.
19   * 
20   * @author Stéphane Nicolas - snicolas@octo.com
21   * @author Benoit Billington
22   * 
23   */
24  @RunWith( MavenJUnitTestRunner.class )
25  @MavenVersions( {"3.0.5", "3.2.5" } )
26  public class LintMojoIntegrationTest
27  {
28      @Rule
29      public final TestResources resources = new TestResources();
30  
31      public final MavenRuntime verifier;
32  
33      public LintMojoIntegrationTest(MavenRuntime.MavenRuntimeBuilder builder)
34      throws Exception
35      {
36          this.verifier = builder.withCliOptions( "-X" ).build();
37      }
38  
39      /**
40       * Test project with skip lint flag to true
41       * 
42       * @throws Exception
43       */
44      @Test
45      public void testSkipConfig() throws Exception
46      {
47          File basedir = resources.getBasedir( "lint-config-project0" );
48          MavenExecutionResult result = verifier
49                  .forProject(basedir)
50                  .execute( PluginInfo.getQualifiedGoal( "lint" ) );
51  
52          result.assertErrorFreeLog();
53  
54          result.assertLogText( "Skipping lint analysis" );
55      }
56  
57      /**
58       * Tests execution of Lint
59       * 
60       * @throws Exception
61       */
62      @Test
63      public void testDefaultUnskippedLintConfig() throws Exception
64      {
65          File basedir = resources.getBasedir( "lint-config-project1" );
66          MavenExecutionResult result = verifier
67                  .forProject(basedir)
68                  .execute( PluginInfo.getQualifiedGoal( "lint" ) );
69  
70          result.assertErrorFreeLog();
71  
72          result.assertLogText( "Lint analysis completed successfully" );
73      }
74  
75  }