Browse Source

Merge pull request #963 in DESIGN/design from ~YAOH.WU/design:feature/10.0 to feature/10.0

* commit '215703525ac1bad0c62f02ff690ba8872f2b58c9':
  无任务,单元测试
  无任务,单元测试
research/10.0
yaoh.wu 5 years ago
parent
commit
0806e3ada9
  1. 1
      designer-base/src/test/java/com/fr/design/actions/help/TutorialActionTest.java
  2. 16
      designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java
  3. 2
      designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java

1
designer-base/src/test/java/com/fr/design/actions/help/TutorialActionTest.java

@ -24,6 +24,7 @@ public class TutorialActionTest extends TestCase{
GeneralContext.setLocale(pt);
String ptKey = action.createDocKey();
assertTrue(ptKey.contains(pt.toString()));
GeneralContext.setLocale(Locale.CHINA);
}
public void testServerOnline() {

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

@ -2,6 +2,7 @@ package com.fr.design.formula;
import com.fr.general.GeneralUtils;
import com.fr.invoke.Reflect;
import com.fr.log.FineLoggerFactory;
import org.easymock.EasyMock;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -9,10 +10,10 @@ import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import static junit.framework.Assert.fail;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
/**
* Created by plough on 2018/12/7.
@ -20,6 +21,7 @@ import static org.junit.Assert.assertFalse;
@RunWith(PowerMockRunner.class)
@PrepareForTest(GeneralUtils.class)
public class FunctionConstantsTest {
@Test
public void testNewInstanceFail() throws Exception {
try {
@ -31,7 +33,7 @@ public class FunctionConstantsTest {
}
@Test
public void testEmbedFuntionsAfterStaticInit() {
public void testEmbedFunctionsAfterStaticInit() {
NameAndTypeAndFunctionList[] embFunctionLists = FunctionConstants.EMBFUNCTIONS;
// 一共有 8 个分类
assertEquals(8, embFunctionLists.length);
@ -43,13 +45,17 @@ public class FunctionConstantsTest {
}
@Test
public void testCommonFuntionsAfterStaticInit() {
public void testCommonFunctionsAfterStaticInit() {
NameAndFunctionList commonFunctionList = FunctionConstants.COMMON;
assertEquals(9, commonFunctionList.getDescriptions().length);
}
@Test
public void testIsCustomFormulaPathRunWithCode() {
// mock 的 GeneralUtils.readBuildNO()).andReturn("不是安装版本").anyTimes()
// 会影响 FunctionConstants.class 静态代码块 loadEmbededFunctions 执行,先加载这个类,执行静态代码块
FineLoggerFactory.getLogger().info(String.valueOf(FunctionConstants.EMBFUNCTIONS.length));
PowerMock.mockStatic(GeneralUtils.class);
EasyMock.expect(GeneralUtils.readBuildNO()).andReturn("不是安装版本").anyTimes();
PowerMock.replayAll();
@ -63,6 +69,10 @@ public class FunctionConstantsTest {
@Test
public void testIsCustomFormulaPathRunWithJar() {
// mock 的 GeneralUtils.readBuildNO()).andReturn("不是安装版本").anyTimes()
// 会影响 FunctionConstants.class 静态代码块 loadEmbededFunctions 执行,先加载这个类,执行静态代码块
FineLoggerFactory.getLogger().info(String.valueOf(FunctionConstants.EMBFUNCTIONS.length));
PowerMock.mockStatic(GeneralUtils.class);
EasyMock.expect(GeneralUtils.readBuildNO()).andReturn("Build#release-2018.12.10.12.11.09.95").anyTimes();
PowerMock.replayAll();

2
designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java

@ -56,6 +56,8 @@ public class TemplateInfoCollectorTest {
initialFileContent = FileUtils.readFileToString(new File(filePath), "utf-8");
Reflect.on(TemplateInfoCollector.class).set("instance", null);
// 后执行 testReadXML 用例时,之前保留的单例会造成影响
Reflect.on(DesignerOpenHistory.class).set("singleton", null);
}
@After

Loading…
Cancel
Save