18
Aug
经常被人们拿来与JUnit进行比较的框架是TestNG,它的灵感来源于JUnit。Michael Minella提供了一个JUnit和TestNG的简洁但有用的对比表。
| 特性 | JUnit | TestNG |
| 用户自定义生命周期 | ![]() |
![]() |
| 测试的组织(组等等) | ![]() |
|
| 分布式测试 | ![]() |
|
| 并行测试 | ![]() |
|
| 数据驱动测试 | ![]() |
|
| 依赖测试 | ![]() |
|
| IDE集成 | ![]() |
![]() |
| Ant集成 | ![]() |
![]() |
| Maven集成 | ![]() |
![]() |
| 特定领域的扩展(数据库、HTTP等) | ![]() |
|
| 活跃的社区 | ![]() |
![]() |
来源
为了总结其想法,他采用了JUnit并对其进行了比TestNG更多的扩展,然而TestNG似乎提供了更多的功能,它还可以调用JUnit测试,这使其成为测试框架的一个诱人之选。
21
Jul
下面是代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | import java.util.Locale; import javax.servlet.http.HttpServletRequest; import org.apache.tiles.context.TilesRequestContext; import org.apache.tiles.locale.impl.DefaultLocaleResolver; import org.springframework.web.servlet.support.RequestContextUtils; /** * Tiles LocaleResolver adapter that delegates to a Spring * {@link org.springframework.web.servlet.LocaleResolver}, * exposing the DispatcherServlet-managed locale. * * <p>This adapter gets automatically registered by {@link TilesConfigurer}. * If you are using standard Tiles bootstrap, specify the name of this class * as value for the init-param "org.apache.tiles.locale.LocaleResolver". * * @author Juergen Hoeller * @since 2.5 * @see org.apache.tiles.definition.UrlDefinitionsFactory#LOCALE_RESOLVER_IMPL_PROPERTY */ public class SpringLocaleResolver extends DefaultLocaleResolver { public Locale resolveLocale(TilesRequestContext context) { if (context.getRequest() instanceof HttpServletRequest) { return RequestContextUtils.getLocale((HttpServletRequest) context.getRequest()); } else { return super.resolveLocale(context); } } } </p> |
上面是代码
归类于:未分类
标签:



















