unable to find resource 'xxx\xx\overview.vm' in any resource loader.
ResourceManager : unable to find resource 'C:\Test\TestConfig\overview.vm' in any resource loader.
org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'C:\Test\TestConfig\overview.vm'
at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:474)
at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:352)
at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1533)
at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1514)
at org.apache.velocity.app.VelocityEngine.getTemplate(VelocityEngine.java:373)
at baseReport.GenerateReporter.generateReport(GenerateReporter.java:28)
at org.testng.TestNG.generateReports(TestNG.java:1076)
at org.testng.TestNG.run(TestNG.java:1001)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)
导致的原因是overview.vm路径不正确
换了一种写法,注释掉的是之前的,对比下
package baseReport; import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import org.testng.*;
import org.testng.xml.XmlSuite; import java.io.*;
import java.util.List;
import java.util.Map;
import java.util.Properties; public class GenerateReporter implements IReporter { @Override
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites,
String outputDirectory) {
// TODO Auto-generated method stub
try {
// 初始化并取得Velocity引擎
VelocityEngine ve = new VelocityEngine();
Properties p = new Properties();
String fileDir=".//TestConfig/";
//p.setProperty("resource.loader", "class");
//p.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
//ve.init(p);
//Template t = ve.getTemplate("main/java/baseReport/overview.vm");
p.setProperty(ve.FILE_RESOURCE_LOADER_PATH, fileDir); //此处的fileDir可以直接用绝对路径来
ve.init(p); //初始化
Template t = ve.getTemplate("overview.vm");//此处只要指明文件名就可以了.
VelocityContext context = new VelocityContext(); for (ISuite suite : suites) {
Map<String, ISuiteResult> suiteResults = suite.getResults();
for (ISuiteResult suiteResult : suiteResults.values()) {
ReporterData data = new ReporterData();
ITestContext testContext = suiteResult.getTestContext();
// 把数据填入上下文
context.put("overView", data.testContext(testContext));//测试结果汇总信息
//ITestNGMethod[] allTests = testContext.getAllTestMethods();//所有的测试方法
//Collection<ITestNGMethod> excludeTests = testContext.getExcludedMethods();//未执行的测试方法
IResultMap passedTests = testContext.getPassedTests();//测试通过的测试方法
IResultMap failedTests = testContext.getFailedTests();//测试失败的测试方法
IResultMap skippedTests = testContext.getSkippedTests();//测试跳过的测试方法
//IResultMap starttime=testContext.getStartDate();
//IResultMap endtime=testContext.getEndDate(); context.put("pass", data.testResults(passedTests, ITestResult.SUCCESS));
context.put("fail", data.testResults(failedTests, ITestResult.FAILURE));
context.put("skip", data.testResults(skippedTests, ITestResult.FAILURE));
}
}
// 输出流 OutputStream out = new FileOutputStream("report.html");
Writer writer = new BufferedWriter(new OutputStreamWriter(out, "utf-8"));//解决乱码问题
// 转换输出
t.merge(context, writer);
//System.out.println(writer.toString());
writer.flush();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
unable to find resource 'xxx\xx\overview.vm' in any resource loader.的更多相关文章
- java.lang.UnsatisfiedLinkError: Unable to load library 'xxx': Native library (win32-x86-64/ID_Fpr.dll)
使用 JNA 调用 dll 库,因为 dll 库是32 位的,而 jvm 是 64位的,所以发生的错误: java.lang.UnsatisfiedLinkError: Unable to load ...
- LoadRunner执行过程报错“Failed to connect to server "xxx.xxx.xxx.xxx:xx":[10060] connetion time out”
执行性能测试过程中,LR报错: Action.c(6):Error -27796: Failed to connect to server "xxx.xxx.xxx.xxx:xx" ...
- Visual Studio发布Web项目报错:Unable to add 'xxx' to the Web site. Unable to add file 'xxx'. The specified file could not be encrypted.
背景 Visual Studio下的Web项目 现象 发布时遇到Unable to add 'xxx' to the Web site. Unable to add file 'xxx'. The ...
- sudo: unable to resolve host XXX 解决方法
执行sudo命令时候,总是提示sudo: unable to resolve host xxx 解决方法: 法1. 在/etc/hosts/添加hosts映射, 如127.0.0.1 xxx 法2. ...
- 您为这个网络适配器输入的IP地址xxx.xxx.xxx.xx已经分配给另一个适配器xxx...
您为这个网络适配器输入的IP地址xxx.xxx.xxx.xx已经分配给另一个适配器‘xxx NIC’.... 2008年11月03日 星期一 08:51 问题现象: 在网卡的TCP/IP属性中无法 ...
- 执行发送邮件Send方法时,报错:邮箱不可用。 服务器响应为: 5.7.1 Unable to relay for xxx@xxx.com
.net代码在执行发送邮件Send方法时,往往出现这个的报错: 邮箱不可用. 服务器响应为: 5.7.1 Unable to relay for xxx@xxx.com 这个问题应该是smtp的设置问 ...
- Python中的xxx == xx是否等价于xxx is xxx
先上代码: >>> a = 1 >>> b = 1 >>> a is b True >>> a == b True what? ...
- git clone 报错Unable to negotiate with xxx.xxx.xxx.xxx port 12345: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1
在执行git clone命令报错 Unable to negotiate with xxx.xxx.xxx.xxx port 12345: no matching key exchange metho ...
- Git clone 报错 Unable to negotiate with xxx.xxx.xxx.xxx port 12345: no matching cipher found. Their offer: aes128-cbc,3des-cbc,blowfish-cbc
git clone 报错 Unable to negotiate with xxx.xxx.xxx.xxx. port 12345: no matching cipher found. Their o ...
随机推荐
- 容器集成平台 rancher部署
下载rancher镜像 docker pull rancher/server:stable rancher/server:latest #开发版 rancher/server:stable #稳定版 ...
- centos迷你版,没有安装ifconfig命令
ifconfig命令是设置或显示网络接口的程序,可以显示出我们机器的网卡信息,可是有些时候最小化安装CentOS等Linux发行版的时候会默认不安装ifconfig等命令,这时候你进入终端,运行ifc ...
- discuz formhash
class.core.php中 $this->var['formhash'] = formhash();define('FORMHASH', $this->var['formhash']) ...
- Python Socket编程基础篇
Socket网络编程 socket通常也称作"套接字",用于描述IP地址和端口,是一个通信链的句柄,应用程序通常通过"套接字"向网络发出请求或者应答网络请求. ...
- Zooming
Zooming 是一款纯 javascript 图片缩放库,主要特点有: 不依赖其他库,纯 JavaScript 实现,支持移动设备: 流畅的动画: 可缩放高清图像: 易于集成和定制. 使用方法 1. ...
- 填格子3*N的方框使用2*1的矩形进行填充
考虑每个位置的前一个状态 可以发现有 我们分别给他们编号 假设 现在填充到了i+1行,我们可以发现从i行可以通过填充转到i+1行的状态 第i行第j列表示 可以 从上一个转态 j 可以到达这个状态的j ...
- python 星号*使用方法
1.乘号 2.表示倍数 def T(msg,time=1): print((msg+',,')*time) >>>T('hi',3) hi,,hi,,hi 3.单个星号* --1-- ...
- 虚拟环境Scrapy安装
1.进入安装的虚拟环境(安装虚拟环境请参考我的博客“在windows下安装Python虚拟环境”) 2.pip install Scrapy
- ajax请求头设置 | header 传token
$('.w-entry-btn').on('tap',function(){ var urlAddress = '/api/address'; var valToken = JSON.parse(lo ...
- silverlight数据绑定
控件绑定 <Grid x:Name="LayoutRoot"> <StackPanel> <ScrollBar x:Name="bar&qu ...