Testing Spring applications

14 06 2014

Very good reference conference speech about Spring applications testing strategies and frameworks. Older Spring apps (with web.xml) are covered, as well as the spring 3+, where config is made by annotations and Java Classes.

Unit and Integration tests are presented. The speech itself is conducted with quite monotonic voice, however it is fully packed with information, knowledge and live demos:





Why TDD is hard?

7 04 2012

Test Driven Development is not about testing – it’s about the design. It is worth to remember that the idea of preparing tests first is difficult if You are preapring… tests. It is much easier when You see it as a design requirements. After that, You test if design requirements are met by software. Not only test the if the software works correctly itself.

Tests are prepared first, then the software is written. The goal is to design software in detail so that test cases check if software meets requirements.

This is new way of thinking about software that is in common with Agile methodology. Software is created from the users’ point of view. First You define (in tests) how software has to look like and work, then just implement it so that all the test cases are fulfilled. There is no doubt that this is the right approach.

The problem is that writing the tests, developer does not write software itself, but give his time to other tasks. The clue is to believe that this will save time and resources in future – simply by limiting the amount of bugs that would consume developer’s time if not discovered in early phase with TDD.

It is not easy to write tests that will reveal all bugs, but spending more time on particular part of software code increases its quality itself.  I still did not managed skill of writing test ahead of software, but I am doing my best!

Do you like my blog?
I manage this blog and share my knowledge for free sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality

Donate Button with Credit Cards

Thank You!





Android jUnit test for asynchronous tasks

24 03 2012

Android dialog is example of using asynchronous background tasks in Android. In my case it was downloading data from server and a dialog box with “Please wait…” text. Here is a good AsyncTask example, and below – how it goes in my case:

  1. AsyncTask is started in activity OnStart() along with showing dialog box
  2. Data is being downloaded in inner class extending AsyncTask
  3. After data is downloaded the dialog box is dismissed and further data processing initialized (in the OnPostExecute() method)

Everything works very well until it comes to jUnit testing. The cause is dialog box invocation that throws an exception:

java.lang.IllegalArgumentException: View not attached to window manager

The cause is that displaying and hiding dialog box causes updating the activity, so the activity must exist also when dialog box is being dismissed.

jUnit test is running so fast that the activity is being destroyed before the dialog box is dismissed in AsyncTask. Then it would be great to hold on the test execution (even if everything was already tested) until the dialog box will disapear and then destroy the whole activity. The solution is small lib – Awaitility.

Awaitility enables to wait until some condition is met or the timer is exceeded. So there is possibility to check if dialog box was dismissed and hold test execution until it happens – with few lines of code. See the simpliest samples from Awaitility site.

In my case I used just:

Awaitility.await().until(dataIsDownloaded());

along with a flag in tested activity, indicating if data downloading has finished. dataIsDownloaded() just checks if this flag is set to true. I put this lin of code in tearDown() method, as data downloaded is not needed for my test – i just have to wait for a dialog box to be dismissed until finishing the activity under tests.

Did I help you?
I manage this blog and share my knowledge for free sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality

Donate Button with Credit Cards

Thank You!





Best Android TDD tutorials

17 03 2012

There is not very much help on android Test Driven Development on the Internet. However I can recommend some tutorials listed below and desribed with details further in text. Most of examples covers the temperature converter which is surely very poor example of Android application… And definitely not the real life case of the killer app…

1. YouTube podcast just to relax and listen at the very beginning

2. Diego Torres lecture (the best so far)

3. Android Application Testing from Packt – worth giving a try if the two above are not enough

Reasons for my recommendations:

1. In order jus to listen as an introduction it is worth to spend 5 minutes on this YouTube podcast. There is no technical details mentioned, just basics and assumptions on TDD. Really good to listen to have some high – level information about what You are going to learn and use.

2. All the necessary basics are covered by Diego Torres lectures. Some theoretical introduction and practical examples of UI and logic testing. This is of course not everything that is needed to do TDD in Android, but it’s the best starting point. There is no details about ActivityUnitTestCase, which is also important to use in Android App testing.

3. Book requires much more time and concentration to read so it is recommended only if two above sorces are not enough (they aren’t in my case). Is it worth reading? As I heven’t found nothing better – it seems to be. It is not the best one. Still searching…

If there are more tutorials hidden on the Internet – please let me know! :)

Did I help you?
I manage this blog and share my knowledge for free sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality

Donate Button with Credit Cards

Thank You!








%d bloggers like this: