Browse Source

Pull request #12246: REPORT-94637 design包部分单测修复

Merge in DESIGN/design from ~LEVY.XIE/design:release/11.0 to release/11.0

* commit 'd545ba2b7d7b22d2d7f1a9344731c69d3cb90e84':
  REPORT-94637 单测修复
  REPORT-94637 单测修复
release/11.0
Levy.Xie-解安森 1 year ago
parent
commit
495862af19
  1. 1
      build.gradle
  2. 4
      designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java
  3. 12
      designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java
  4. 17
      designer-base/src/test/java/com/fr/design/gui/icombocheckbox/UICheckListPopupTest.java

1
build.gradle

@ -90,6 +90,7 @@ allprojects {
testImplementation 'org.easymock:easymock:3.5.1' testImplementation 'org.easymock:easymock:3.5.1'
testImplementation 'org.powermock:powermock-module-junit4:1.7.1' testImplementation 'org.powermock:powermock-module-junit4:1.7.1'
testImplementation 'org.powermock:powermock-api-easymock: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' testImplementation 'junit:junit:4.12'
} }

4
designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java

@ -16,8 +16,8 @@ public class FormulaPaneTest extends TestCase {
@Test @Test
public void testSimilarComparator() { public void testSimilarComparator() {
String[] strs = new String[] {"ScriptEval", "SPLIT", "SUMPRECISE"}; String[] strs = new String[]{"ScriptEval", "SPLIT", "SUMPRECISE"};
String[] result = new String[] {"SPLIT", "ScriptEval", "SUMPRECISE"}; String[] result = new String[]{"SPLIT", "SUMPRECISE", "ScriptEval"};
Arrays.sort(strs, new FormulaPane.SimilarComparator("sp")); Arrays.sort(strs, new FormulaPane.SimilarComparator("sp"));
Assert.assertArrayEquals(result, strs); Assert.assertArrayEquals(result, strs);
} }

12
designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java

@ -1,12 +1,16 @@
package com.fr.design.formula; package com.fr.design.formula;
import com.fr.design.i18n.Toolkit;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.invoke.Reflect; import com.fr.invoke.Reflect;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import org.easymock.EasyMock; import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.easymock.PowerMock; import org.powermock.api.easymock.PowerMock;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
@ -19,9 +23,15 @@ import static org.junit.Assert.fail;
* Created by plough on 2018/12/7. * Created by plough on 2018/12/7.
*/ */
@RunWith(PowerMockRunner.class) @RunWith(PowerMockRunner.class)
@PrepareForTest(GeneralUtils.class) @PrepareForTest({GeneralUtils.class, Toolkit.class})
public class FunctionConstantsTest { public class FunctionConstantsTest {
@Before
public void setUp() {
PowerMockito.mockStatic(Toolkit.class);
PowerMockito.when(Toolkit.i18nText(Mockito.anyString())).thenReturn("test");
}
@Test @Test
public void testNewInstanceFail() throws Exception { public void testNewInstanceFail() throws Exception {
try { try {

17
designer-base/src/test/java/com/fr/design/gui/icombocheckbox/UICheckListPopupTest.java

@ -1,8 +1,16 @@
package com.fr.design.gui.icombocheckbox; package com.fr.design.gui.icombocheckbox;
import com.fr.design.i18n.Toolkit;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before;
import org.junit.Test; 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.ArrayList;
import java.util.List; import java.util.List;
@ -14,8 +22,17 @@ import java.util.TreeMap;
* @version 10.0 * @version 10.0
* Created by hades on 2020/4/3 * Created by hades on 2020/4/3
*/ */
@RunWith(PowerMockRunner.class)
@PrepareForTest(Toolkit.class)
@PowerMockIgnore("javax.swing.*")
public class UICheckListPopupTest extends TestCase { public class UICheckListPopupTest extends TestCase {
@Before
public void setUp() {
PowerMockito.mockStatic(Toolkit.class);
PowerMockito.when(Toolkit.i18nText(Mockito.anyString())).thenReturn("test");
}
@Test @Test
public void testGetSelectedValues() { public void testGetSelectedValues() {
Object[] values = new Object[]{"a", "b", "c"}; Object[] values = new Object[]{"a", "b", "c"};

Loading…
Cancel
Save