@@ -13,6 +13,9 @@ import org.junit.Rule
13
13
import org.junit.Test
14
14
import org.junit.rules.ExpectedException
15
15
16
+ import javax.swing.text.NumberFormatter
17
+ import java.text.NumberFormat
18
+
16
19
/**
17
20
* Copied from the Internet, just to check if we have correct exception thrown.
18
21
*/
@@ -41,17 +44,6 @@ class CauseMatcher extends TypeSafeMatcher<Throwable> {
41
44
}
42
45
43
46
class OverallCheckTaskTest {
44
- private static Locale defaultLocale
45
- @BeforeClass
46
- public static void setup () {
47
- defaultLocale = Locale . getDefault()
48
- Locale . setDefault(Locale . US )
49
- }
50
-
51
- @AfterClass
52
- public static void tearDown () {
53
- Locale . setDefault(defaultLocale)
54
- }
55
47
56
48
@Rule
57
49
public ExpectedException expectedException = ExpectedException . none()
@@ -60,6 +52,7 @@ class OverallCheckTaskTest {
60
52
Project project = ProjectBuilder . builder(). build()
61
53
project. plugins. apply(ScoveragePlugin )
62
54
project. tasks. create(' bob' , OverallCheckTask ) {
55
+ locale = Locale . US
63
56
minimumRate = coverageRate
64
57
reportDir = new File (' src/test/resources' )
65
58
coverageType = type
@@ -74,6 +67,7 @@ class OverallCheckTaskTest {
74
67
Project project = ProjectBuilder . builder(). build()
75
68
project. plugins. apply(ScoveragePlugin )
76
69
project. tasks. create(' bob' , OverallCheckTask ) {
70
+ locale = Locale . US
77
71
minimumRate = 1.0
78
72
reportDir = new File (' src/test/nothingthere' )
79
73
coverageType = CoverageType.Line
@@ -114,9 +108,10 @@ class OverallCheckTaskTest {
114
108
@Test
115
109
void failsWhenStatementRateIsBelowTarget () {
116
110
Project project = projectForRate(1 , CoverageType.Statement )
111
+ NumberFormat nf = NumberFormat . getInstance()
117
112
expectedException. expectCause(new CauseMatcher (
118
113
GradleException . class,
119
- OverallCheckTask . errorMsg(" 33.33" , " 100" , CoverageType.Statement )
114
+ OverallCheckTask . errorMsg(nf . format( new Double ( 33.33 )) , " 100" , CoverageType.Statement )
120
115
))
121
116
project. tasks. bob. execute()
122
117
}
0 commit comments