-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTestRunnerTest.java
More file actions
85 lines (74 loc) · 2.55 KB
/
TestRunnerTest.java
File metadata and controls
85 lines (74 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package org.utplsql.api;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.utplsql.api.compatibility.CompatibilityProxy;
import org.utplsql.api.exception.SomeTestsFailedException;
import org.utplsql.api.reporter.*;
import org.utplsql.api.rules.DatabaseRule;
import java.sql.Connection;
import java.sql.SQLException;
/**
* Created by Vinicius on 13/04/2017.
*/
public class TestRunnerTest {
@Rule
public final DatabaseRule db = new DatabaseRule();
@Test
public void runWithDefaultParameters() {
try {
Connection conn = db.newConnection();
new TestRunner().run(conn);
} catch (SQLException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void runWithoutCompatibilityCheck() {
try {
Connection conn = db.newConnection();
new TestRunner()
.skipCompatibilityCheck(true)
.run(conn);
} catch (SQLException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void runWithManyReporters() {
try {
Connection conn = db.newConnection();
new TestRunner()
.addPath(db.getUser())
.addReporter(new DocumentationReporter().init(conn))
.addReporter(new CoverageHTMLReporter().init(conn))
.addReporter(new CoverageSonarReporter().init(conn))
.addReporter(new CoverallsReporter().init(conn))
.addReporter(new SonarTestReporter().init(conn))
.addReporter(new TeamCityReporter().init(conn))
.addReporter(new XUnitReporter().init(conn))
.run(conn);
} catch (SQLException e) {
Assert.fail(e.getMessage());
}
}
@Test
/** This can only be tested on frameworks >= 3.0.3
*/
public void failOnErrors() {
try {
Connection conn = db.newConnection();
CompatibilityProxy proxy = new CompatibilityProxy(conn);
if ( proxy.getDatabaseVersion().isGreaterOrEqualThan(new Version("3.0.3"))) {
new TestRunner()
.failOnErrors(true)
.run(conn);
Assert.fail();
}
} catch (SomeTestsFailedException ignored) {
System.out.println("Expected exception object thrown.");
} catch (Exception e) {
Assert.fail("Wrong exception object thrown: " + e.getMessage());
}
}
}