Powermock 不断为 ScriptEngineManager 抛出错误
由于我想在我的测试中使用JUnit的类别,我不得不用PowerMock重写一些模拟测试(Powermock在EasyMock之上模拟静态)。从RunWith(PowermockRunner.class)到下面;
@Category(ServerTests.class)
@PrepareForTest(EnvironmentConfig.class)
@PowerMockIgnore( {"javax.management.*", "org.w3c.dom.*", "org.apache.log4j.*", "org.xml.sax.*", "javax.xml.*"})
public class JmsHelperTest {
@Rule
public PowerMockRule rule = new PowerMockRule();
}
不幸的是,我已经用PowerMockIgnore抑制了一些错误,但最后一个我无法抑制,我希望你能提供帮助。
错误:
ScriptEngineManager providers.next(): javax.script.ScriptEngineFactory: Provider jdk.nashorn.api.scripting.NashornScriptEngineFactory not a subtype ScriptEngineManager providers.next(): javax.script.ScriptEngineFactory: Provider jdk.nashorn.api.scripting.NashornScriptEngineFactory not a subtype 2017-06-09 13:37:24,660 main ERROR No ScriptEngine found language javascript.可用语言是: 2017-06-09 13:37:24,776 主 WARN 找不到名为 {} 的脚本
供参考,加载的包;
import mypackage.EnvironmentConfig;
import mypackage.category.ServerTests;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.rule.PowerMockRule;
import static org.easymock.EasyMock.expect;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;
import static org.powermock.api.easymock.PowerMock.mockStatic;
import static org.powermock.api.easymock.PowerMock.replay;