Spring MVC
SpringMVC是基于MVC思想的JAVA WEB实现框架,是Spring家族的一员,它基于前置控制器来接收并分发请求,支持参考验证、请求参数封装、拦截、Restful等功能,是目前较为流行的MVC框架
本系列学习笔记包含如下的课程内容:
- MVC思想
- Hello案例
- 请求和响应处理
- 文件上传和下载处理
- 参数验证
- 请求拦截
- RESTful风格
- 日志
TestNG
TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use, such as:
- Annotations.
- Run your tests in arbitrarily big thread pools with various policies available (all methods in their own thread, one thread per test class, etc…).
- Test that your code is multithread safe.
- Flexible test configuration.
- Support for data-driven testing (with @DataProvider).
- Support for parameters.
- Powerful execution model (no more TestSuite).
- Supported by a variety of tools and plug-ins (Eclipse, IDEA, Maven, etc…).
- Embeds BeanShell for further flexibility.
- Default JDK functions for runtime and logging (no dependencies).
- Dependent methods for application server testing.
pom.xml
1 | <dependency> |
service 单元测试
1 | import org.springframework.beans.factory.annotation.Autowired; |
控制器 单元测试
1 | import com.tz.WebMvcConfig; |
Run
mvn test -Dtest=ServiceConfigTest -Dgroups=g1
ormvn test -Dtest=ServiceConfigTest -Dgroups=g1,g2
断言异常
1 | @Test(expectedExceptions = SomeException.class) |
控制执行顺序
priority
1 | 1) (priority= |
dependsOn
In TestNG, you use dependsOnMethods and/or dependsOnGroups:
1 | "a") (groups = |
or
1 |
|