Skip to main content

Posts

Showing posts with the label Testing

A simple way to mock objects without using mock unit testing framework

When writing unit test, there are some cases that I have to mock objects: It makes sense to mock provided objects by libraries (APIs) such as FacesContext (JSF) because of no real environment running. It makes sense to mock a lower layer objects and it is already tested, for example: mocking Dao layer objects when testing Service layer (Service calls Dao) . At beginning I was aware of Mockito (a mocking framework) in order to overcome the issue. And currently, I am interested in another way like an alternative because it looks more simple. That is just create mock objects manually and just do anything we want. I've just known this approach from Primefaces' source code. :) Follow my simple example below and we can see what different from these 2 ways are: I have an interface Foo and a class Bar public interface Foo { String greet(); } public class Bar { public String greet(Foo foo){ return foo.greet(); } } Using Mockito example: public class M

Agile Testing - A defense system from my team stories

Today, I love to tell you about my team story about testing. That started from no testing to extreme testing system.  eXtreme Feedback Devices (https://jenkins.io/blog/2013/09/05/ext reme-feedback-lamp-switch-gear-style/ ) Guess what? That is really an exciting idea from the picture(no?). These devices can work with Jenkins. Whenever they build a Jenkins job, this system notifies instantly to developers the status of their system. That is not 100% related to testing but somehow it is like our testing mindset. Because, in my team,  we call our testing system is a defense system :). There is no doubt that it is very hard for us to remember all features of our applications even which is developed for a long time. Like a document, tests help us make sure no features will be lost after changes such as adding new more features, fixing bugs or refactoring code. That was the reason why we cared much about testing. It was really important for developing apps. Back then, we th