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.的更多相关文章

  1. 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 ...

  2. 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" ...

  3. 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 ...

  4. sudo: unable to resolve host XXX 解决方法

    执行sudo命令时候,总是提示sudo: unable to resolve host xxx 解决方法: 法1. 在/etc/hosts/添加hosts映射, 如127.0.0.1 xxx 法2. ...

  5. 您为这个网络适配器输入的IP地址xxx.xxx.xxx.xx已经分配给另一个适配器xxx...

    您为这个网络适配器输入的IP地址xxx.xxx.xxx.xx已经分配给另一个适配器‘xxx NIC’.... 2008年11月03日 星期一 08:51 问题现象:   在网卡的TCP/IP属性中无法 ...

  6. 执行发送邮件Send方法时,报错:邮箱不可用。 服务器响应为: 5.7.1 Unable to relay for xxx@xxx.com

    .net代码在执行发送邮件Send方法时,往往出现这个的报错: 邮箱不可用. 服务器响应为: 5.7.1 Unable to relay for xxx@xxx.com 这个问题应该是smtp的设置问 ...

  7. Python中的xxx == xx是否等价于xxx is xxx

    先上代码: >>> a = 1 >>> b = 1 >>> a is b True >>> a == b True what? ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. 2018-2019-2 网络对抗技术 20165324 Exp1:PC平台逆向破解

    2018-2019-2 网络对抗技术 20165324 Exp1:PC平台逆向破解 实验: 要求: 掌握NOP, JNE, JE, JMP, CMP汇编指令的机器码(0.5分) 掌握反汇编与十六进制编 ...

  2. Python线程,进程,携程,I/O同步,异步

    只有本人能看懂的-Python线程,进程,携程,I/O同步,异步 举个栗子: 我想get三个url,先用普通的for循环 import requests from multiprocessing im ...

  3. random随机数应用

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. windows下docker的安装并使用

    硬件虚拟化:硬件虚拟化是一种对计算机或操作系统的虚拟.虚拟化对用户隐藏了真实的计算机硬件,表现出另一个抽象计算平台. 打开任务管理器的性能查看是否支持虚拟化技术 下载windows docker ht ...

  5. 【调优】Nginx性能调优

    一.Nginx优化配置 1.主配置文件优化:# vi /usr/local/nginx/conf/nginx.conf----------------------------------------- ...

  6. Asp.net Mvc5的认识

    前言:以前总说自己玩mvc,但是对mvc的认识还是不够透彻,也没有好好看微软自带的mvc项目中的精妙,最近闲了下来,好好看了看. 通过上图,我们可以清晰地了解到MVC 5应用程序的项目结构,接下来我们 ...

  7. Python 迭代器切片

    函数itertools.islice() 正好适用于在迭代器和生成器上做切片操作 >>> def count(n): ... while True: ... yield n ... ...

  8. WSDL解析

    背景 前面我们介绍过利用javassist动态生成webservice,这种方式可以使得我们系统通过页面配置动态发布webservice服务,做到0代码开发发布北向接口.进一步思考,我们如何0代码开发 ...

  9. python选择排序算法总结

    选择排序算法: a=[6,5,4,3,2,1] 算法思路: 第一步:在列表的第一个位置存放此队列的最小值 声明一个变量min_index等于列表的第一个坐标值0 从第一个位置0坐标开始,和它后边所有的 ...

  10. 20145101《Java程序设计》第三周学习总结

    20145101 <Java程序设计>第3周学习总结 教材学习内容总结 本周进行的是第四章和第五章的学习.本阶段的学习难度有所提升,无论是在知识的量还是深度都开始增加,内容很丰富,也很有趣 ...