English 中文(简体)
纽约总部 j网应用试验
原标题:Run JUnit Test from a java web application

Is it possible to run JUnit Tests from a java web application (on a Tomcat server) ?

How can I with a click on a link, launch the instantiation of an object ? or the call to a method ?

非常感谢。

最佳方面。

问题回答

Sure, although I m not sure why you d want to.

See the cookbook example, nutshell:

org.junit.runner.JUnitCore.runClasses(TestClass1.class, ...);

显然,你需要部署测试班,以便补上班级,并将扼制班名改为实际的<代码>。 类别

You d likely also need to scan for annotations or convention-based class names; there are a variety of ways to do that including things like the reflections library.

IMO it d be easier to set up a continuous integration (CI) server like Jenkins or CruiseControl etc. and get a complete package, but it depends on what your needs actually are.

There a number of JUnit-based frameworks that can assist with web testing.

Jwebunit

Canoo Webtest

HttpUnit

HtmlUnit





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签