Personal opinion on software development in general, development methodologies, tools and best practices in particular

Archive for the ‘Uncategorized’ Category

7 mistakes of software testing


Though most developers know the importance of testing, it seems that a lot of them still aren’t testing enough. And if they write tests, they test just test wrong.

Unit tests

If some tests are written in applications, most of them will be unit tests. It’s easy to test a utility class by just calling all utility methods, passing some values and checking if the expected result is returned.

A first mistake arises here. Most people don’t think out of the box, or not enough. You can test that 1 + 1 =2 , that 2 + 1 = 3 and that 3 + 1 = 4. But what’s the benefit of doing almost the same test 3 times? It’s better to test the boundary cases. Are the arguments of the sum( ) method primitive types or Objects? If they are Objects, what happens if you pass null values? If an exception is thrown, is that the expected one? Does it clearly tell what the problem is?

Mocks

If for example the service layer is unit tested, all other components like the DAO layer should be mocked. In many cases this is done manually. That’s a second mistake.

By mocking stuff manually your mocks are thightly coupled to the implementation. It’s much better to use mocking frameworks. They are made for it. Just trust that they will create the mocks the way you want. Some mocking frameworks are capable of doing more than others, some are easier to use than others. My favourite mocking framework is Mockito because of its power and simplicity. EasyMock is by far the best known but imo a bit too complex to use. What was the sequence again? Expect, replay, assert, or …?

So it’s not only a matter of choosing a mocking framework. It’s also a matter of choosing the right one.

Integration tests

Integration tests are tests over different integrated parts of an application while unit tests only tests a LUW (logical unit of work). The best known type of integration tests are   tests of the DAO layer. In these tests, multiple things are validated: the input parameters, the use of the ORM tool, the correctness of the generated query (functional), if the DB can be accessed, the fact that the query is working and the fact that the correct ResultSet is returned.

A third mistake that is made often is that developers provide test data in a dbUnit XML dataset. This data is most of the time no representation of live data. The best way to handle this is to make functional people provide and maintain this test data. Because you don’t want to make them struggle with a specific XML format, it’s a good practice to use the XlsDataSet format. Data can be provided in an Excel sheet. The name of the tab is the table, in the first row, each column contains the name of the column and in all other rows, effective data is added. Insertion into the DB will be done tab per tab, from left to right. Deletion is done the other way around.

Functional tests

Functional test are forgotten too often because the perception is that they are difficult and costly to maintain. It’s true that you’ll have to tweak them to make them maintainable but executing all the same tests manually over and over again will cost much more. Also when functionality is tested and automated by means of continuous integration, there’s no need for stress for screens/functionality that will be broken in the next release.

Selenium is a great framework that is able to record functionality in the browser. A fourth mistake is made here. Most people will just record and replay the tests the way they are. Selenium keeps tracks of HTML components by their HTML id. If you don’t specify id’s in your HTML code, they can easily change if a page is updated. This will break the tests immediately even when functionality still works.

A fifth mistake is made by just pasting the recorded test in a JUnit test. Common functionality like login and logout, the time to wait for a response, … should be added to a higher level. For example, a login can be done before each test, afterwards a logout is done. This way, if something changes in login or logout functionality, tests won’t break.

A sixth mistake is the absence of testing logical flows. It’s perfectly possible that an insert, a search, an update, and a delete work on their own but that the complete flow from the creation, search, update until delete of the same entry won’t work. TestSuites are a great way to group multiple tests and run them in sequence all together.

BDD

Mistake nr seven: most of the tests are technical tests instead of functional tests. It’s much more important to test logical behaviour than to test if the things work technically. That can be done by means of Behavior Driven Design.
Given some things, when an event occurs, then what should be the outcome? Mockito has some great stuff to easily write tests in a BDD way.

Advertisements

What if there were no innovative companies in IT?


Recently I was wondering how the web, technology market, gadgets, … should look like if there were no big innovators the last few years. I thought it was worth it to share my thoughts with you.

What if there was no Google?

We would probably still combine all kind of search engine’s suboptimal search results to find what we need on the web. Maybe there would exist some portal which combines these results but they wouldn’t be good at all and you would still be able to get high rankings by putting some words a thousand times in the meta data of your HTML source.

We would probably still write our documents offline, use crappy mail programs where conversations don’t exist and we always had to search for related mails if a new reply was sent. Navigation, maps-software would always lead you to the wrong place and web app interfaces would be ugly, bloated and absolutely not user friendly.

Probably for all the software, good or bad, user friendly or not, we should pay, wait months for bug fixes and new features and had to renew our license every year.

Google just has a great business model. They just improve the web instead of just selling software or licenses and that’s what I like about that company!

What if there no good alternatives for IE?

WEB 2.0 would probably not exist because there was no innovation in the browser world. Developers and web designers would get angry because of all the incompatibilities and the lack of following standards.

Due to Opera, Safari, Mozilla Firefox and Chrome, HTML5 and CSS3 will be adopted, the web will be richer and you can create a site that just works fine without ugly hacks for every new browser version.

I’m glad Microsoft finally phases out IE6 and has set up a campaign to discourage people to use IE6. I’m also glad about the way Microsoft changed, due to competition. IE9 doesn’t support CSS3 and HTML5 very well but at least it supports the new W3C standards instead of using custom CSS styles… And soon there will be IE10 which will support CSS3 and HTML5 much better. If they don’t, IE will just lose a lot of market share.

What if there was no Apple?

We would still use ugly, not user friendly mp3 players that look like an USB stick with a small screen. Tablets and smartphones maybe wouldn’t exist or at least they would be less popular. 1 problem I have with Apple is that it’s all about the hype and that their products are expensive, but they are innovative and of great quality.

Conclusion: innovation drives IT and the rest of the world. Stagnation means decline…

2010 in review


The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here’s a high level summary of its overall blog health:

Healthy blog!

The Blog-Health-o-Meter™ reads Wow.

Crunchy numbers

Featured image

A Boeing 747-400 passenger jet can hold 416 passengers. This blog was viewed about 9,100 times in 2010. That’s about 22 full 747s.

 

In 2010, there were 8 new posts, not bad for the first year! There were 39 pictures uploaded, taking up a total of 2mb. That’s about 3 pictures per month.

The busiest day of the year was May 10th with 592 views. The most popular post that day was How to make Scrum fail.

Where did they come from?

The top referring sites in 2010 were dzone.com, javablogs.com, facebook.com, twitter.com, and Google Reader.

Some visitors came searching, mostly for scrum, vaadin, vaadin maven, code review wtf, and jsf lifecycle.

Attractions in 2010

These are the posts and pages that got the most views in 2010.

1

How to make Scrum fail May 2010
10 comments

2

Vaadin: what’s new September 2010
3 comments

3

Vaadin, Maven and Spring June 2010
2 comments

4

Why webapps? March 2010
2 comments

5

Standards: Pros and cons February 2010
5 comments