Jukito 介绍
JUnit、 Guice、 Mockito 高效组合测试框架。
如果你使用 Google Guice,或者如果你的GWT应用程序使用
Gin,那么,Jukito
是解决你的单元测试头痛的灵丹妙药。现在,你可进行如下测试:
@RunWith(JukitoRunner.class) public class EmailSystemTest { @Inject EmailSystemImpl emailSystem; Email dummyEmail; @Before public void setupMocks( IncomingEmails incomingEmails, EmailFactory factory) { dummyEmail = factory.createDummy(); when(incomingEmails.count()).thenReturn(1); when(incomingEmails.get(0)).thenReturn(dummyEmail); } @Test public void shouldFetchEmailWhenStarting( EmailView emailView) { // WHEN emailSystem.start(); // THEN verify(emailView).addEmail(dummyEmail); } }
或者:
@RunWith(JukitoRunner.class) public class CalculatorTest { public static class Module extends JukitoModule { protected void configuretest() { bindMany(Calculator.class, ScientificCalculator.class, BusinessCalculator.class); bindManyInstances(AdditionExample.class, new AdditionExample(1, 1, 2), new AdditionExample(10, 10, 20), new AdditionExample(18, 24, 42)); } } @Test public void testAdd(@All Calculator calculator, @All AdditionExample example) { // WHEN int result = calculator.add(example.a, example.b); // THEN assertEquals(example.expected, result); } }
Jukito 官网
https://github.com/ArcBees/Jukito
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。