- 授权协议: Apache
- 开发语言: Java
- 操作系统: 跨平台
- 软件首页: https://github.com/google/acai
软件介绍
Acai 是 JUnit4 和 Guice 的测试库,可以更容易的编写应用功能测试。
主要特性:
注入测试需要的助手类
启动测试需要的任意的服务
运行测试之间的服务清理
按照正确顺序启动多个服务
创建测试作用域绑定
Acai 主要针对的是应用大型功能测试。
安装
<dependency> <groupId>com.google.acai</groupId> <artifactId>acai</artifactId> <version>0.1</version> <scope>test</scope> </dependency>
使用 Acai 进行测试注入
@RunWith(JUnit4.class)
public class SimpleTest {
@Rule public Acai acai = new Acai(MyTestModule.class);
@Inject private MyClass foo;
@Test
public void checkSomethingWorks() {
// Use the injected value of foo here
}
private static class MyTestModule extends AbstractModule {
@Override protected void configure() {
bind(MyClass.class).to(MyClassImpl.class);
}
}
}使用 Acai 启动服务
@RunWith(JUnit4.class)
public class ExampleFunctionalTest {
@Rule public Acai acai = new Acai(MyTestModule.class);
@Inject private MyServerClient serverClient;
@Test
public void checkSomethingWorks() {
// Call the running server and test some behaviour here.
// Any state will be cleared by MyFakeDatabaseWiper after each
// test case.
}
private static class MyTestModule extends AbstractModule {
@Override protected void configure() {
// Normal Guice modules which configure your
// server with in-memory versions of backends.
install(MyServerModule());
install(MyFakeDatabaseModule());
install(new TestingServiceModule() {
@Override protected void configureTestingServices() {
bindTestingService(MyServerRunner.class);
bindTestingService(MyFakeDatabaseWiper.class);
}
});
}
}
private static class MyServerRunner implements TestingService {
@Inject private MyServer myServer;
@BeforeSuite void startServer() {
myServer.start().awaitStarted();
}
}
private static class MyFakeDatabaseWiper implements TestingService {
@Inject private MyFakeDatabse myFakeDatabase;
@AfterTest void wipeDatabase() {
myFakeDatabase.wipe();
}
}
}
疯狂Java讲义
李刚 / 电子工业出版社 / 2012-1-1 / 109.00元
《疯狂Java讲义(附光盘第2版)》是《疯狂Java讲义》的第2版,第2版保持了第1版系统、全面、讲解浅显、细致的特性,全面介绍了新增的Java 7的新特性。 《疯狂Java讲义(附光盘第2版)》深入介绍了Java编程的相关方面,全书内容覆盖了Java的基本语法结构、Java的面向对象特征、Java集合框架体系、Java泛型、异常处理、Java GUI编程、JDBC数据库编程、Java注释、......一起来看看 《疯狂Java讲义》 这本书的介绍吧!
