Warning |
---|
This page is DEPRECATED, please refer to the new source http://struts.apache.org/plugins/junit/ |
The JUnit plugin
Excerpt |
---|
provides integration with the popular JUnit unit testing framework |
...
First, include the plugin your POM (if using Maven 2) under the test scope:
Code Block | ||
---|---|---|
| ||
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-junit-plugin</artifactId>
<version>STRUTS_2_VERSION</version>
<scope>test</scope>
</dependency>
|
if you are using Spring, also add:
Code Block | ||||
---|---|---|---|---|
| ||||
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>STRUTS_2_VERSION</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>test</scope>
</dependency>
|
...
Now, your JUnit tests can subclass the StrutsTestCase
class, which handles starting and stopping the Struts 2 framework:
Code Block | ||
---|---|---|
| ||
public class MyTest extends StrutsTestCase {
// testing code
}
|
...