@@ -13,6 +13,9 @@ import org.junit.Rule
1313import org.junit.Test
1414import org.junit.rules.ExpectedException
1515
16+ import javax.swing.text.NumberFormatter
17+ import java.text.NumberFormat
18+
1619/**
1720 * Copied from the Internet, just to check if we have correct exception thrown.
1821 */
@@ -41,17 +44,6 @@ class CauseMatcher extends TypeSafeMatcher<Throwable> {
4144}
4245
4346class 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- }
5547
5648 @Rule
5749 public ExpectedException expectedException = ExpectedException . none()
@@ -60,6 +52,7 @@ class OverallCheckTaskTest {
6052 Project project = ProjectBuilder . builder(). build()
6153 project. plugins. apply(ScoveragePlugin )
6254 project. tasks. create(' bob' , OverallCheckTask ) {
55+ locale = Locale . US
6356 minimumRate = coverageRate
6457 reportDir = new File (' src/test/resources' )
6558 coverageType = type
@@ -74,6 +67,7 @@ class OverallCheckTaskTest {
7467 Project project = ProjectBuilder . builder(). build()
7568 project. plugins. apply(ScoveragePlugin )
7669 project. tasks. create(' bob' , OverallCheckTask ) {
70+ locale = Locale . US
7771 minimumRate = 1.0
7872 reportDir = new File (' src/test/nothingthere' )
7973 coverageType = CoverageType.Line
@@ -114,9 +108,10 @@ class OverallCheckTaskTest {
114108 @Test
115109 void failsWhenStatementRateIsBelowTarget () {
116110 Project project = projectForRate(1 , CoverageType.Statement )
111+ NumberFormat nf = NumberFormat . getInstance()
117112 expectedException. expectCause(new CauseMatcher (
118113 GradleException . class,
119- OverallCheckTask . errorMsg(" 33.33" , " 100" , CoverageType.Statement )
114+ OverallCheckTask . errorMsg(nf . format( new Double ( 33.33 )) , " 100" , CoverageType.Statement )
120115 ))
121116 project. tasks. bob. execute()
122117 }
0 commit comments