Previously we have seen how to do Unit testing with Mockito; import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; public class SomeBusinessMockTests { @Tes…
It is recommened to write unit testing with Mockito in Spring framework, because it is much faster with Spring framework test. But in case you can doing MVC, you still need to use spring framework test. In this post, we need to understand why to use…
Sometimes when writing a unit test, you know that the module you're testing imports a module that you would like to observe, or at the very least mock to prevent side effects like network activity or file system operations. For JavaScript unit tests…
What's the difference between DOM and SAX? DOM creates tree-like representation of the XML document in memory, SAX is event-based.  What's the difference between XSD and DTD? XSD is in XML, DTD is not. XSD is much more comprehensive than DTD You're g…
Original link: http://www.petrikainulainen.net/programming/spring-framework/unit-testing-of-spring-mvc-controllers-normal-controllers/ Unit Testing of Spring MVC Controllers: “Normal” Controllers by PETRI KAINULAINEN on JULY 7, 2013 The first part of…
Original Link: http://www.petrikainulainen.net/programming/spring-framework/unit-testing-of-spring-mvc-controllers-configuration/ Unit Testing of Spring MVC Controllers: Configuration by PETRI KAINULAINEN on JUNE 28, 2013 Writing unit tests for Sprin…
http://www.opensourcetesting.org/unit_c.php API Sanity AutoTest Description: An automatic generator of basic unit tests for a shared C/C++ library. It helps to quickly generate simple ("sanity" or "shallow"-quality) test cases for ever…
本文将简单介绍如何使用PowerMock和Mockito来mock1. 构造函数2. 静态函数3. 枚举实现的单例4. 选择参数值做为函数的返回值5. 在调用mock出来的方法中,改变方法参数的值 一点简要说明:Mockito其实已经可以满足大部分的需求,但是它的实现机制是使用cglib来动态创建接口的类的实例.但是这种实现方式不能用于构造函数和静态函数,因为那需要使用类的字节码(比如使用javassist). 所以我们才需要结合使用PowerMock. 1. mock构造函数, 如果有代码没有…
之前一直对这两个注解的区别不是很明白. 搜到过一篇博客园的文章举例说明了代码行为的区别.后来在stackoverflow上看到一个问答简单明了的解释了这两个注解在定义上的区别: 在此翻译记录一下: //译文Begin: @Mock: 创建一个Mock. @InjectMocks: 创建一个实例,其余用@Mock(或@Spy)注解创建的mock将被注入到用该实例中. 注意:必须使用@RunWith(MockitoJUnitRunner.class) 或 Mockito.initMocks(this…
转自https://www3.ntu.edu.sg/home/ehchua/programming/java/JavaUnitTesting.html yet another insignificant programming notes...   |   HOME TABLE OF CONTENTS (SHOW) Java Unit Testing -  & TestNG 1.  Introduction to Unit Testing Framework The various type o…