Browse Source

REPORT-94637 单测修复

newui
Levy.Xie 1 year ago
parent
commit
07361237d8
  1. 1
      build.gradle
  2. 2
      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.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'
}

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

@ -17,7 +17,7 @@ public class FormulaPaneTest extends TestCase {
@Test
public void testSimilarComparator() {
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"));
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;
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 {

17
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"};

Loading…
Cancel
Save