Skip to content

Commit 3acad4b

Browse files
committed
Added skip test
1 parent 3f307c5 commit 3acad4b

File tree

2 files changed

+113
-13
lines changed

2 files changed

+113
-13
lines changed

src/test/java/org/utplsql/maven/plugin/test/UtPLSQLMojoTest.java

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
import org.utplsql.maven.plugin.model.ReporterParameter;
2323
import org.utplsql.maven.plugin.reporter.ReporterWriter;
2424

25+
import java.io.ByteArrayOutputStream;
2526
import java.io.File;
27+
import java.io.PrintStream;
2628
import java.sql.Connection;
2729
import java.util.ArrayList;
2830
import java.util.List;
@@ -39,7 +41,7 @@
3941
import static org.powermock.api.mockito.PowerMockito.when;
4042

4143
@RunWith(PowerMockRunner.class)
42-
@PrepareForTest({ DBHelper.class, ReporterFactory.class })
44+
@PrepareForTest({DBHelper.class, ReporterFactory.class})
4345
public class UtPLSQLMojoTest {
4446

4547
@Rule
@@ -68,7 +70,7 @@ public void setUp() throws Exception {
6870

6971
/**
7072
* testInvalidSourcesDirectory.
71-
*
73+
* <p>
7274
* Given : a pom.xml with invalid sources' directory When : pom is read and
7375
* buildSourcesOptions is run Then : it should throw a MojoExecutionException
7476
*/
@@ -84,12 +86,11 @@ public void testInvalidSourcesDirectory() throws Exception {
8486
thrown.expectMessage("Invalid <SOURCES> in your pom.xml");
8587

8688
Whitebox.invokeMethod(utplsqlMojo, "buildSourcesOptions");
87-
8889
}
8990

9091
/**
9192
* testInvalidTestsDirectory.
92-
*
93+
* <p>
9394
* Given : a pom.xml with invalid tests' directory When : pom is read and
9495
* buildTestsOptions is run Then : it should throw a MojoExecutionException
9596
*/
@@ -109,7 +110,7 @@ public void testInvalidTestsDirectory() throws Exception {
109110

110111
/**
111112
* testSourcesTestsParameters.
112-
*
113+
* <p>
113114
* Given : a pom.xml with sources and tests with a lot of parameters When : pom
114115
* is read and buildSourcesOptions / buildTestsOptions are run Then : it should
115116
* fill all parameters correctly
@@ -150,12 +151,11 @@ public void testSourcesTestsParameters() throws Exception {
150151
assertEquals(1, tests.getTypeMappings().size());
151152
assertEquals("def", tests.getTypeMappings().get(0).getKey());
152153
assertEquals("abc", tests.getTypeMappings().get(0).getValue());
153-
154154
}
155155

156156
/**
157157
* testSourcesAndTestsParameterDoesNotExist.
158-
*
158+
* <p>
159159
* Given : a pom.xml with no sources / tests tags and default directory does not
160160
* exist. When : pom is read and buildSourcesOptions / buildTestsOptions are run
161161
* Then : it should not find any source files
@@ -177,7 +177,7 @@ public void testSourcesAndTestsParameterDoesNotExist() throws Exception {
177177

178178
/**
179179
* testSourcesAndTestsParameterDoesNotExistButDefaultDirectoryExists.
180-
*
180+
* <p>
181181
* Given : a pom.xml with no sources / tests tags but default directory exists.
182182
* When : pom is read and buildSourcesOptions / buildTestsOptions are run Then :
183183
* it should find all sources/tests files in default directories
@@ -199,12 +199,11 @@ public void testSourcesAndTestsParameterDoesNotExistButDefaultDirectoryExists()
199199
assertEquals(2, tests.getFilePaths().size());
200200
assertTrue(tests.getFilePaths().contains("src/test/plsql/foo/f1.pkg"));
201201
assertTrue(tests.getFilePaths().contains("src/test/plsql/f2.pkg"));
202-
203202
}
204203

205204
/**
206205
* testSourcesAndTestsParameterHaveNotDirectoryTag.
207-
*
206+
* <p>
208207
* Given : a pom.xml with source and test tag not containing a directory tag.
209208
* When : pom is read and buildSourcesOptions / buildTestsOptions are run Then :
210209
* it should find all sources/tests files in default directories
@@ -231,7 +230,7 @@ public void testSourcesAndTestsParameterHaveNotDirectoryTag() throws Exception {
231230

232231
/**
233232
* testSourcesAndTestsParameterHaveNotDirectoryTag.
234-
*
233+
* <p>
235234
* Given : a pom.xml with source and test tag not containing a directory tag.
236235
* When : pom is read and buildSourcesOptions / buildTestsOptions are run Then :
237236
* it should find all sources/tests files in default directories
@@ -284,8 +283,7 @@ public void testDefaultConsoleBehaviour() throws Exception {
284283

285284
// Assert that we added only the necessary reporters to the writer.
286285
ReporterWriter reporterWritter = Whitebox.getInternalState(utplsqlMojo, "reporterWriter");
287-
List<Pair<Reporter, ReporterParameter>> listReporters =
288-
Whitebox.getInternalState(reporterWritter, "listReporters");
286+
List<Pair<Reporter, ReporterParameter>> listReporters = Whitebox.getInternalState(reporterWritter, "listReporters");
289287
assertEquals(3, listReporters.size());
290288

291289
ReporterParameter reporterParameter1 = listReporters.get(0).getRight();
@@ -324,4 +322,20 @@ public void testAddDefaultReporter() throws Exception {
324322
assertEquals("UT_DOCUMENTATION_REPORTER", reporterList.get(0).getTypeName());
325323
verify(reporterList.get(0)).init(mockConnection);
326324
}
325+
326+
@Test
327+
public void testSkipUtplsqlTests() throws Exception {
328+
UtPLSQLMojo utplsqlMojo = (UtPLSQLMojo) rule
329+
.lookupConfiguredMojo(new File("src/test/resources/skipUtplsqlTests/"), "test");
330+
Assert.assertNotNull(utplsqlMojo);
331+
332+
final ByteArrayOutputStream console = new ByteArrayOutputStream();
333+
System.setOut(new PrintStream(console));
334+
335+
utplsqlMojo.execute();
336+
337+
String standardOutput = console.toString();
338+
339+
Assert.assertTrue(standardOutput.contains("utPLSQLTests are skipped."));
340+
}
327341
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>org.utplsql</groupId>
7+
<artifactId>utplsql-maven-plugin-test</artifactId>
8+
<version>3.1.0-SNAPSHOT</version>
9+
10+
<packaging>pom</packaging>
11+
12+
<name>utplsql-maven-plugin Maven Plugin Test</name>
13+
14+
<url>http://utplsql.org</url>
15+
16+
<properties>
17+
<dbUrl>jdbc:oracle:thin:@180.129.3.101:1521:xe</dbUrl>
18+
<dbUser>ut3</dbUser>
19+
<dbPass>XNtxj8eEgA6X6b6f</dbPass>
20+
</properties>
21+
22+
<build>
23+
24+
<directory>../../../target/</directory>
25+
26+
<plugins>
27+
<plugin>
28+
<groupId>org.utplsql</groupId>
29+
<artifactId>utplsql-maven-plugin</artifactId>
30+
<version>{project.version}</version>
31+
32+
<goals>
33+
<goal>test</goal>
34+
</goals>
35+
36+
<configuration>
37+
<skipUtplsqlTests>true</skipUtplsqlTests>
38+
39+
<ignoreFailure>false</ignoreFailure>
40+
41+
<paths>
42+
<path>:plsql</path>
43+
</paths>
44+
45+
<reporters>
46+
<reporter>
47+
<name>UT_DOCUMENTATION_REPORTER</name>
48+
</reporter>
49+
<reporter>
50+
<name>UT_DOCUMENTATION_REPORTER</name>
51+
<consoleOutput>false</consoleOutput>
52+
</reporter>
53+
<reporter>
54+
<name>UT_COVERAGE_SONAR_REPORTER</name>
55+
<fileOutput>coverage-sonar-reporter.xml</fileOutput>
56+
</reporter>
57+
<reporter>
58+
<name>UT_SONAR_TEST_REPORTER</name>
59+
<fileOutput>utplsql/sonar-test-reporter.xml</fileOutput>
60+
<consoleOutput>true</consoleOutput>
61+
</reporter>
62+
</reporters>
63+
64+
<sources>
65+
<source>
66+
<directory>foo</directory>
67+
<includes>
68+
<include>**/*sql</include>
69+
</includes>
70+
</source>
71+
</sources>
72+
73+
<tests>
74+
<test>
75+
<directory>bar</directory>
76+
<includes>
77+
<include>**/*.spc</include>
78+
<include>**/*.bdy</include>
79+
</includes>
80+
</test>
81+
</tests>
82+
</configuration>
83+
</plugin>
84+
</plugins>
85+
</build>
86+
</project>

0 commit comments

Comments
 (0)