I released the starter package of my Test With Spring course. Take a look at the course >>

What Kind of Example Application Do You Want to See in My Testing Book?

Idea concept on chalkboard

I have been planning to write a Spring testing book for some time now. About a month ago I tried to create a table of contents for the book. I failed miserably.

The problem was that although I know what should be in the book, I found it hard to write my thoughts down. I decided to stop thinking about it and try again when I feel inspired. That was a big mistake. As you probably figured out, the inspiration never came.

This Is My Idea

Today I decided to take a bit different approach:

I started think what kind of example application I should write. I came up with following requirements:

  • It should support multiple authentication mechanisms (form login, social sign in, and so on).
  • It should have a file upload function.
  • It should have scheduled jobs.
  • It should be possible to implement the application as a single page application and as a normal Spring MVC application.
  • It should use relational database and NoSQL database as a data storage.

After I had created this list, I had an idea about one possible example application. The example application could be a simple to-do list which has the following requirements:

  • It must be possible to create an user account by using form and social sign in (and so on).
  • It must be possible to authenticate by using form login and social sign in (and so on).
  • It must have crud functions for to-do items.
  • It must be possible group to-do items by adding tags to them.
  • It must be possible to search to-do items.
  • It must be possible to list to-do items which are tagged with a specific tag.
  • It must be possible to add file attachments to to-do items.
  • It must be possible to send email reminders to user when the due date of an open to-do item is approaching.
  • Only the owner of a to-do item can see or modify its information.

What Do You Want?

Before I start to implement this application, I want to hear your opinion about it. Your feedback is very valuable to me because I want to write a book which is both interesting and useful. I would appreciate if you would answer to these questions:

  • Did I miss an essential requirement?
  • Is the example application good enough for this kind of book? If not, what would be a better choice?

Thank you for your time!

About the Author

Petri Kainulainen is passionate about software development and continuous improvement. He is specialized in software development with the Spring Framework and is the author of Spring Data book.

About Petri Kainulainen →

21 comments… add one
  • I would like to see users having different roles/permissions. Perhaps, to-do lists can be shared/assigned.

    Reply
    • Thank you for you feedback. The application definitely needs different roles/permissions. Also, I will think about your other ideas (sharing to-do lists). It is true that adding to-do lists (which contains to-do items) to the application would make the application feel more “real”.

      Reply
  • I´m glad to know that you want to write a book about testing Spring applications. Your tutorial is great.

    I think this book should talk about:

    • spring security
    • behaviour driven development
    • acceptance tests
    • integration tests
    • unit tests
    • automated UI testing (something similar to Capybara for Ruby)
    • BDD and TDD cycle
    Reply
    • Thank you for your feedback! It is very useful to me because it helps me to figure out what problems other developers are facing when writing tests for Spring powered web applications.

      Reply
  • Answering your questions.

    >> Did I miss an essential requirement?
    Not that I can think of.

    >> Is the example application good enough for this kind of book? If not, what would be a better choice?
    It´s good enough. Not too simple and not too complex.

    Best Regards,

    Henrique Santos

    Reply
    • Thank you for answering my questions as well. I will probably add to-do lists to the example application as Mihhail suggested but that will probably be the only feature which I add (unless someone proposes something extremely cool).

      Reply
  • It would be great, if you added a little bit more about security.

    Reply
    • Hi Mike,

      I was planning to add multiple roles (regular user and administrators). Administrators can naturally do everything. Regular users can do the following this:

      • Create new to-do lists.
      • Modify the information of a to-do list if the user created it.
      • Delete a to-do list if the user created it.
      • List the items of a to-do list (if the list is shared with the user or the user created it).
      • Add items to to-do lists (if the list is shared with the user or the user created it).
      • Modify to-do items (if the item belongs to a list which is shared with the user or the user created it).
      • Delete a to-do item if the user created it.
      • Attach files to a to-do item (if the item belongs to a list which is shared with the user or the user created it).

      Also, I plan to support multiple authentication mechanisms (form login, social sign in, and so on).

      Do you think that I missed something?

      Reply
      • Sounds great. Is it possible to add session management, like to save session when user logs of and restore it on next log in?

        Reply
        • Thanks for the suggestion! I will add a remember me function to the example application (this is actually supported by Spring Security so I don’t have to write any code).

          Reply
  • Hi,

    Great idea. I would definitive would like to read about testing views. As with JSP it is hard, with such engine as Thymeleaf it is possible.

    The application could also be equipped with a RESTfull API, so testing of RESTfull API could be be presented.

    Reply
    • I was planning to write two different versions of the example application:

      • A “normal” Spring MVC application with JSP views.
      • A single page application which uses REST API.

      Now that you mentioned it, I should probably consider implementing a version which uses Thymeleaf (It seems to be quite popular at the moment).

      Thanks you for your comment!

      Reply
      • That is a very good idea to have two separate apps.

        Reply
  • I came to your site by searching how to unit test Spring applications. I have to say that the example you are thinking of is the most exhaustive. Looking forward for the book.

    Thanks,
    Ananth.

    Reply
    • Thank your for your kind words. I really appreciate them. Also, it is good to know that the requirements of the example application are good enough.

      Reply
  • Consider voting on todo items incorporating abillity for users to be ‘watchers’.
    Consider chat on todo items.
    These could be then showcased as vertical slices.
    thymeleaf +1
    modularisation with servlet 3 web-fragments might be interesting in a testing context

    Reply
    • Thank you for leaving this comment.

      You left this comment in the best possible time because I have just started to implement the first example application. I will blog about the example applications when I have got something to show.

      I haven’t decided what features are included but I promise that one example application will use Thymeleaf.

      Reply
  • Hi Petri,

    Have you considered using something like leanpub to get feedback while writing your book? Or perhaps Packt have something similar (never heard of it though). Mentioning Packt because of your other book (Spring Data – which I own btw (but haven’t read ^^; … yet!)).

    This is probably going to sound like a stupid question – what exactly does one test with regards to JSPs / Thymeleaf (not familiar with the latter)? As in, using Spring. I’m not very familiar with testing the view layer to be honest but I would imagine the tests would be somewhere along the lines of querying the DOM and making sure its structured as you expect. Selenium comes to mind. But Spring tests? Not sure how they fit in. I mean you could test the REST API, but the views?

    +1 for the SPA approach. What front end technologies do you intend to use? But I guess since this is intended to be a Spring testing book, you will not be writing about testing the front end, will you?

    Cheers

    Reply
    • Hi Justin,

      I am sorry that it took me some to answer to your comment.

      Have you considered using something like leanpub to get feedback while writing your book? Or perhaps Packt have something similar (never heard of it though). Mentioning Packt because of your other book (Spring Data – which I own btw (but haven’t read ^^; … yet!)).

      To be honest, I haven’t really thought about this. At the moment I am writing the first example application and the progress is a bit slower than I expected (mainly because I want to work on other things too). I think that I will pay some attention to this before I start the writing process.

      This is probably going to sound like a stupid question – what exactly does one test with regards to JSPs / Thymeleaf (not familiar with the latter)?

      If you use JSP, you cannot write any tests to the views because JSP rendering isn’t available outside a servlet container. You can only test the correct view is rendered and that the model contains the correct model attributes (amongst other things).

      On the other hand, if you use Thymeleaf, you can write tests for the views because the response will contain the generated content. If you want to get more information about this, you should read the blog post series that provides an introduction to Spring Test MVC HtmlUnit. The first blog post of that series is titled : Introducing Spring Test MVC HtmlUnit.

      What front end technologies do you intend to use?

      I will use AngularJS.

      But I guess since this is intended to be a Spring testing book, you will not be writing about testing the front end, will you?

      I haven’t thought about this either but I think that it might be better to leave this topic out from this book (mainly because otherwise the scope might be too big for me). I will write tests for the front end code though.

      Reply
  • HI Petri,

    In your book, could you please discuss Debugging MockMVC unit test? I expected a 200 response, but instead am getting a 404 response. Maybe include the different tools used for debugging JSON like Firebug. Also , not just 404 errors, but 300, 400, 500 errors as well. Thanks for Spring Data, BTW. Great book!

    Reply
    • Hi Matt,

      Thank you for your suggestion. I decided that I won’t write another book. However, I decided to create a video course that helps you to write automated tests for Spring web applications. I will include your idea in that course.

      P.S. It was great to hear that you like my book.

      Reply

Leave a Comment