diff --git a/build.gradle b/build.gradle index a0599e7549..f9c687731c 100644 --- a/build.gradle +++ b/build.gradle @@ -90,6 +90,7 @@ allprojects { testImplementation 'org.easymock:easymock:3.5.1' testImplementation 'org.powermock:powermock-module-junit4:1.7.1' testImplementation 'org.powermock:powermock-api-easymock:1.7.1' + testImplementation 'org.powermock:powermock-api-mockito2:1.7.4' testImplementation 'junit:junit:4.12' } diff --git a/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java b/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java index 4ac71b5ac0..c6a646bbc7 100644 --- a/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java +++ b/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java @@ -16,8 +16,8 @@ public class FormulaPaneTest extends TestCase { @Test public void testSimilarComparator() { - String[] strs = new String[] {"ScriptEval", "SPLIT", "SUMPRECISE"}; - String[] result = new String[] {"SPLIT", "ScriptEval", "SUMPRECISE"}; + String[] strs = new String[]{"ScriptEval", "SPLIT", "SUMPRECISE"}; + String[] result = new String[]{"SPLIT", "SUMPRECISE", "ScriptEval"}; Arrays.sort(strs, new FormulaPane.SimilarComparator("sp")); Assert.assertArrayEquals(result, strs); } diff --git a/designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java b/designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java index b53d47780c..1c00f5bdc1 100644 --- a/designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java +++ b/designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java @@ -1,12 +1,16 @@ package com.fr.design.formula; +import com.fr.design.i18n.Toolkit; import com.fr.general.GeneralUtils; import com.fr.invoke.Reflect; import com.fr.log.FineLoggerFactory; import org.easymock.EasyMock; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mockito; import org.powermock.api.easymock.PowerMock; +import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -19,9 +23,15 @@ import static org.junit.Assert.fail; * Created by plough on 2018/12/7. */ @RunWith(PowerMockRunner.class) -@PrepareForTest(GeneralUtils.class) +@PrepareForTest({GeneralUtils.class, Toolkit.class}) public class FunctionConstantsTest { + @Before + public void setUp() { + PowerMockito.mockStatic(Toolkit.class); + PowerMockito.when(Toolkit.i18nText(Mockito.anyString())).thenReturn("test"); + } + @Test public void testNewInstanceFail() throws Exception { try { diff --git a/designer-base/src/test/java/com/fr/design/gui/icombocheckbox/UICheckListPopupTest.java b/designer-base/src/test/java/com/fr/design/gui/icombocheckbox/UICheckListPopupTest.java index 33a98e078d..a35055c2fd 100644 --- a/designer-base/src/test/java/com/fr/design/gui/icombocheckbox/UICheckListPopupTest.java +++ b/designer-base/src/test/java/com/fr/design/gui/icombocheckbox/UICheckListPopupTest.java @@ -1,8 +1,16 @@ package com.fr.design.gui.icombocheckbox; +import com.fr.design.i18n.Toolkit; import junit.framework.TestCase; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; import java.util.ArrayList; import java.util.List; @@ -14,8 +22,17 @@ import java.util.TreeMap; * @version 10.0 * Created by hades on 2020/4/3 */ +@RunWith(PowerMockRunner.class) +@PrepareForTest(Toolkit.class) +@PowerMockIgnore("javax.swing.*") public class UICheckListPopupTest extends TestCase { + @Before + public void setUp() { + PowerMockito.mockStatic(Toolkit.class); + PowerMockito.when(Toolkit.i18nText(Mockito.anyString())).thenReturn("test"); + } + @Test public void testGetSelectedValues() { Object[] values = new Object[]{"a", "b", "c"};