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 MockitoExampleTes…

Agile Testing - A defense system from my team stories

Today, I would like to tell you about my team stories from no testing to extreme testing system.

I think that is really an exciting idea from the picture above because these devices can work with Jenkins. Whenever they build the Jenkins jobs, this system notify 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 - just a metaphor. :). As we know, 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 is the reason why we care too much about testing. It is really important for developing apps. Next, we think about how to test effectively.
The "testing pyramid" points out that basing on the efforts, the agility of detecting bugs…