简体   繁体   English

如何使用jsp运行测试用例(用junit 3.x和4.x编写)?

[英]How can I run my test cases (which written in junit 3.x and 4.x) using jsp?

I want to run my all test cases which is written in both junit versions(3.x & 4.x) in JSP. 我想运行所有用JSP的两个junit版本(3.x和4.x)编写的测试用例。 If I called that jsp it should run all test cases. 如果我调用了该jsp,它将运行所有测试用例。 Please guide me. 请指导我。

This being odd, there is a way to do it: 这很奇怪,有一种方法可以做到:

You can use JUnitCore.runClasses(..) , where you pass an array of the classes of your unit tests. 您可以使用JUnitCore.runClasses(..) ,在其中传递单元测试的类的数组。

Of cours, you will need a <@% page import="org.junit.runner.JUnitCore" %> in your jsp. 在您的jsp中,您将需要一个<@% page import="org.junit.runner.JUnitCore" %>

Still, tell us your scenario, because this doesn't seem quite right. 不过,请告诉我们您的情况,因为这似乎不太正确。 At least do this in a Servlet , not a jsp 至少在Servlet中而不是jsp中执行此操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM