akuma8 (15) [Avatar] Offline
#1
Hi Craig,

I know the book is almost finished but could you add a new chapter about testing?
In testing I mean : Unit + Integration tests.
I would like to know how can we unit test: "Services", "Repositories", "Controllers", "ControllerAdvices" and "Accessing secured resource"?
This is a big big part of the Spring Framework and you didn't address these topics on the book. I use Spring for 1 year now and I still don't know how to well test with Spring.
Could you PLEASE, add a chapter or even an appendix about testing?
Thanks a lot
10536 (1) [Avatar] Offline
#2
I am wondering why a "Testing in Spring" chapter is not included in this book. Paramount topic that deserves a chapter in this book, by itself.
northernpeople (33) [Avatar] Offline
#3
Have you seen the 4th edition of the book? If you really want to learn testing, and not just complain here, please download 4th edition that you were given as a gift. You will find that testing is integrated into the book throughout. There is very little change in testing(Spring 4 -> 5), as concepts are simple and don't change often.
habuma (279) [Avatar] Offline
#4
I **COMPLETELY** feel your desire for better coverage of testing. There are some elements of testing with Spring covered in the book as well as others not covered in the book, but that will be reflected in the source code that accompanies the book.

That said, I'm sincerely sorry to say that there won't be a dedicated chapter or appendix for testing. There are many reasons for this, including space concerns (the page count is already terribly high and much higher than I had planned) and that I do not believe it best to confine testing to a single chapter, outside of the context of what is being tested. I tried adding testing in here and there throughout the book, alongside what is being tested. But when chapters started to exceed reasonable size, tough choices had to be made and sometimes testing (as well as other subjects) didn't make the cut. It's not that I do not believe testing to be important...I absolutely do!...but that certain topics demanded more attention in the pages of the book than testing. (And again, I sincerely hate that.)

In all honesty, I truly believe that Manning could publish a book dedicated to nothing more than testing with Spring and still fill several hundred pages. There are so many amazing and useful facilities for testing that come with Spring, Spring Boot, Spring Integration, Spring Security, etc, etc, that if I were to cover them all in Spring in Action, the book would easily be another 300+ pages longer and too thick to be printed.

Rather than push to include deeper testing coverage in Spring in Action, maybe I propose to Manning that a book on Spring testing be published? Spring in Action would focus on other elements of Spring with a little testing sprinkled in...whereas "Spring Testing in Action" could focus on testing with just enough of other bits of Spring sprinkled in to give the testing subjects a foundation. WDYT?
akuma8 (15) [Avatar] Offline
#5
@northernpeople I hope you joke when you say
There is very little change in testing
and why releasing a 5th edition if the 4th edition is still relevant?
Regarding testing, Spring Boot comes with some intersting concepts like slice testing with all
@...Test
and as the book is based on Spring Boot I think the author should take at least 1 chapter to explain some testing concepts.
Maybe I shouldn't have bought the book and spent my time reading the docs, it would have been the same.
And I am not complaining, it's just normal for a book about this great framework.
akuma8 (15) [Avatar] Offline
#6
@habuma Thanks for replying.
It is a great idea to devote this subject (testing) in another book. At least we will be able to go in depth and discuss certain concepts in detail.
I look forward to the MEAP. Please let me know.
habuma (279) [Avatar] Offline
#7
Thanks for understanding, even if it's not quite the answer you were hoping for. I've proposed a book on Spring Testing to Manning...now we just wait to see what they say. smilie

A bit more of my thoughts on the matter: Even if I had included a chapter or two on testing in SiA5, I think you'd have been terribly disappointed that it didn't cover the subject deep enough. My previous reply pretty much said this, but again, I think to cover the subject properly would require a book devoted to the subject. Anything less would just be checking a box on a checklist and not really doing it justice. Some topics, such as Spring Security or Spring Integration, would also benefit from a dedicated book, but I can still cover them enough to give the reader a good start on the subject. I feel that testing is different in that if I only give it a chapter, then all I've done is equipped you to test using whatever could fit in that chapter, but not equipped you to make practical use of Spring's testing facilities.

Fingers crossed that Manning will be keen on a book dedicated to testing with Spring!