Automated testing has become something people don't speak about any more. It matured to being a standard in software development, everyone is and should be practicing. No more talks at conferences, only a few blog posts and online articles from now and then. That radically changed recently, again becoming a hotly debated topic, at least after some of @dhh's quite provocative posts and his RailsConf keynote.


I learned about automated testing, particularly unit testing, during my Bachelor studies at university. It was kind of awkward, initially, and we definitely wrote tests to fulfill the submission criteria of our lab projects. After years of practicing, more experience, a dozen of read articles, books, blog posts, I really started to love it. Especially after I felt the pain of having to refactor the codebase without any kind of regression tests in place: you cannot move, you want, but you cannot! A total nightmare, just blindly changing the code, hoping for the best. Stop doing this.


Today I mostly always write automated tests because




  • I got used to it




  • it makes me develop faster




  • it gives me the freedom to improve later; making it possible to quickly code, even a sub-optimal implementation now, because I know I'll be able to change, refactor and optimize it laster more easily




  • ...




Even when coding some quick experiments, I create some automated tests that proof my assumptions. Overkill? I don't think so. There are so many nice tools in place which execute your tests right after you save/compile your code. Would I be faster by writing and executing console.logstatements after each change? Hardly...


Whenever you are tempted to type something into a print statement or a debugger expression, write it as a test instead. Martin Fowler


I simply love the fast feedback I get by looking at the test run indicator while coding, without having to move my fingers from the keyboard to click through some UI for verifying that my code (still) works. Moreover, I build a regression suite: each additional tests I add gets executed after each modification to my code. I'm basically testing all of the scenarios (my and those potentially implemented by my collegues) from the beginning of my coding up to where I currently am, in milliseconds. Can you do the same with the debugger or console.log?? ;)


When I code JavaScript, I write automated tests! Of course, I don't even have a compiler there, everything happens/breaks at runtime. It's even more important than in statically typed, compiled languages. So, hell yes, I do create automated tests that are executed by Jenkins when I commit my feature to make sure I didn't break anything else.


Do I do TDD?


Hmm..I follow a test-first approach, I'd say, and I try to have a cycle like




  1. Implement the test




  2. See it fail




  3. Write code




  4. See test pass




  5. (...)




Admittedly it often slightly distorts to a "implement production code, gosh..this is going to be complicated..need a test, then comment production code out, write test, see it fail, then uncomment the code, see it still fail (?!), write some more production code, see it succeed" kind of workflow. But that's normal I guess.


What about Test Driven Design? You mean to let my architecture evolve blindly by the magic of TDD? Didn't succeed on that (I'd require a mentor here in case someone is interested ;)). I usually think about the architecture or a possible implementation of a feature already before I write the first line of code. This happens automatically. Do the tests influence/change/adapt that initially design during the implementation? Most often, yes. Furthermore, based on the gained experiences in writing lots of tests, my architecture evolved over the years to facilitate testing out of the box.


For me, the important thing to have is automation and fast feedback (which implies having automation in place). Then, I write all kind of tests, depending which on my needs. Automated JMeter tests that call my REST api after each deploy, integration tests going down starting from my frontend controller through the dependency injection framework, the business layer, data access till down to the DB. Unit tests on the other side for reusable components, for critical code, for situations where I wouldn't want to setup data in the DB to test a particular use case and where it's much easier and faster to simply provide some stubs.


The debate: Most unit testing is a waste


The testing debate started with a quite provocative article entitled "Why Most Unit Testing is Waste". In a 19 pages article James O Coplien outlines some issues he encountered while writing unit tests.


If you have the time, absolutely read it, but read the entire article and don't just draw (wrong) conclusions from the headline! Alternatively, Rodolfo Grave created a nice summary on his blog.


Coplien's résumé:




  • Keep regression tests around for up to a year — but most of those will be system-level tests rather than unit tests.




  • Keep unit tests that test key algorithms for which there is a broad, formal, independent oracle of correctness, and for which there is ascribable business value.




  • Except for the preceding case, if X has business value and you can test X with either a system test or a unit test, use a system test — context is everything.




  • Design a test with more care than you design the code.




  • Turn most unit tests into assertions.




  • Throw away tests that haven’t failed in a year.




  • Testing can’t replace good development: a high test failure rate suggests you should shorten development intervals, perhaps radically, and make sure your architecture and design regimens have teeth




  • If you find that individual functions being tested are trivial, double-check the way you incentivize developers’ performance. Rewarding coverage or other meaningless metrics can lead to rapid architecture decay.




  • Be humble about what tests can achieve. Tests don’t improve quality: developers do.




As already Rodolfo comments, other than the "throw tests away", I fully agree. IMHO, this article is written by a person who mastered writing automated tests.


A bit later, David Heinemeier Hansson (@dhh), creator of Ruby on Rails and founder & CTO ofBasecamp, entered the debate with his TDD is dead articles:



..followed by lots of discussions on HackerNews here and here and various ones on Twitter between Martin Fowler, Heinemeier, Uncle Bob Martin and Kent Beck.


Numerous blog posts and articles emerged from these dicussions. Here are some I was able to capture



Someone even started a #WhyITDD hashtag on Twitter.


To conclude: It seems to me that using good design principles that make your tests run faster is a noble goal. It also seems to me that decoupling from frameworks such as Rails, as your applications grow, is a wise action. I believe these things to be evidence that professionals, like Jim Weirich, are at work. Uncle Bob


See, always told you...


If you ever tried to convince/coach people in writing automated tests, then you know how damn hard it is. Personally I think it's nearly impossible. You can only give an initial hint on some techniques and then each dev needs to practice and experience it by himself. It's something that has quite a steep learning curve.


The main problem (I'm quite sick to hear about...) is that devs take those articles mentioned previously as a proof they were correct in not writing any tests in the past and future. This is total non-sense! If you read beyond the headline, none of them questions the creation of automated tests but rather




  • the TDD approach




  • unit tests vs. integration tests vs acceptance tests etc...




Make sure you understand what automated testing is about, what unit tests are, what TDD is all about etc. Fowler's collection of articles might be a good starting point.


Thoughtworks event: "Is TDD dead?"


Martin Fowler announced yesterday that ThoughtWorks will be hosting a debate between himself, Kent Beck and David Heinemeier Hansson about whether TDD is dead. You should absolutely participate at this hangout or watch the recorded session afterwards.


Source : java.dzone.com

Melt


Mat Honan’s Are Touchscreens Melting Your Kid’s Brain?1 set off the latest in what has become a recurring tech theme over the past few years:


I’m perpetually distracted, staring into my hand, ignoring the people around me. Hit Refresh and get a reward, monkey. Feed the media and it will nourish you with @replies and Likes until you’re hungry and bleary and up way too late alone in bed, locked in the feedback loop. What will my daughter’s loop look like? I’m afraid to find out.


This has been a difficult topic for me for a long time. In 2012 I wrote an article for Smashing Magazine called A Dad’s Plea To Developers Of iPad Apps For Children, in which I aired some of my frustrations with apps for kids. That piece brought out a lot of anger, including a comment that I’ll never forget:


Wow really? great parents here.. having a kid under 7 stare at a screen, really?? come on!! no kid under 7 should use an iPad for what?? play outside, play with your toys, your friends, read. People who have a 2yr old use an ipad/iphone, shouldn’t have kids in the first place! shame on you


I started writing a passionate reply, explaining our reasoning and the rules my wife and I have for screen time, but I ended up just dropping it. No one has ever changed their opinion based on a comment they read on a blog, so why bother.


Anyway, I digress. I tend to agree with Robert McGinley Myers’ response to Mat’s article. InScreens Aren’t Evil (which you should read in its entirety) he says:


But we need to get beyond worrying about whether “screens” are melting our kids’ brains. What we need to be conscious of is encouraging our kids, and ourselves, to engage in activities that enrich us. Sometimes that’s interacting with each other, sometimes that’s a hike in the forest, sometimes thats a great book, and sometimes that’s an incredible video game. It’s not the medium that matters, but what we take from it.


Now that’s a moderate stance I can get behind. Source : http://www.elezea.com/

Melt


Mat Honan’s Are Touchscreens Melting Your Kid’s Brain?1 set off the latest in what has become a recurring tech theme over the past few years:


I’m perpetually distracted, staring into my hand, ignoring the people around me. Hit Refresh and get a reward, monkey. Feed the media and it will nourish you with @replies and Likes until you’re hungry and bleary and up way too late alone in bed, locked in the feedback loop. What will my daughter’s loop look like? I’m afraid to find out.


This has been a difficult topic for me for a long time. In 2012 I wrote an article for Smashing Magazine called A Dad’s Plea To Developers Of iPad Apps For Children, in which I aired some of my frustrations with apps for kids. That piece brought out a lot of anger, including a comment that I’ll never forget:


Wow really? great parents here.. having a kid under 7 stare at a screen, really?? come on!! no kid under 7 should use an iPad for what?? play outside, play with your toys, your friends, read. People who have a 2yr old use an ipad/iphone, shouldn’t have kids in the first place! shame on you


I started writing a passionate reply, explaining our reasoning and the rules my wife and I have for screen time, but I ended up just dropping it. No one has ever changed their opinion based on a comment they read on a blog, so why bother.


Anyway, I digress. I tend to agree with Robert McGinley Myers’ response to Mat’s article. InScreens Aren’t Evil (which you should read in its entirety) he says:


But we need to get beyond worrying about whether “screens” are melting our kids’ brains. What we need to be conscious of is encouraging our kids, and ourselves, to engage in activities that enrich us. Sometimes that’s interacting with each other, sometimes that’s a hike in the forest, sometimes thats a great book, and sometimes that’s an incredible video game. It’s not the medium that matters, but what we take from it.


Now that’s a moderate stance I can get behind. Source : http://www.elezea.com/

Leslie M. Ficcaglia, a member of the American Society of Portrait Artists, has been an artist for as long as she can recall. As a child she carried a sketchbook with her and took every opportunity to draw the people and objects she encountered. Largely self-taught, she attended life classes at The Art Students’ League while a student at New York University and more recently studied landscape painting with Glenn Rudderow, of the Pennsylvania Academy of Fine Arts, to learn oil techniques. This experience with landscapes is evident in the backgrounds she uses for her oil portraits. While she is proficient with more formal studies as well, her specialty is “Portraits in a Natural Setting” and she often depicts her subjects out-of-doors, in settings which are meaningful to them. Painting in her studio overlooking the Wild and Scenic Manumuskin River in rural Port Elizabeth, in southern New Jersey, Ficcaglia normally works from her own photographs. She finds that using photos as her reference material enables her to achieve fresher and more spontaneous facial expressions than would be possible if her subjects were asked to pose for long periods of time, and the warmth and sense of personality she is able to convey have become a trade- mark of her work.


photo.jpg


    Ficcaglia’s choice of subject matter reflects both her background in psychology and her strong interest in the environment. Although she has only been doing figurative paintings since 1995 she has already developed a wide reputation for her work. Her portraits in oils have been featured in articles and photographs in local papers, the Press of Atlantic City, and the Philadelphia Inquirer, and have been the subject of a radio interview, and her commissioned works hang in public and private settings in New Jersey, New York, Pennsylvania, Maryland, Florida, Nevada, California and the south of France. Several years ago she was honored to be commissioned by the New Jersey Conference of Mayors to paint a portrait of Governor James McGreevey and his wife, Dina Matos McGreevey, and she now completes the annual Mayor of the Year portrait for that organization. Recently Ficcaglia has begun traveling to France, where she spends time with friends who live there and also explores the countryside. This has provided her with material for a series of mostly figurative paintings based on the people and places she has seen in the Southwest and in Paris.


Leslie Ficcaglia has long been interested in ecotourism as a means of protecting her area's resources. Her ecotourism brochure was distributed by her township and became the core for this web site. She served as a member of the Maurice River Township Planning Board for almost twenty years and as its chair for the last seven years of her tenure, and continues as vice-chairman of the Cumberland County Planning Board. She was active in the effort to obtain federal Wild and Scenic status for the Maurice River and its tributaries, working on the task force established for that purpose. In addition she is the Pinelands Commissioner for Cumberland County and a past trustee for the Association of New Jersey Environmental Commissions. She also sits on the county Tourism Council; serves as vice-chair for the township Environmental Committee; acts as trustee for Citizens United, a local watershed organization; is a member of the Delaware Bayshores Advisory Council of The Nature Conservancy; and chairs the board of the Riverfront Renaissance Center for the Arts. Her biography is listed in Who's Who in America.


Professionally Mrs. Ficcaglia, a retired psychologist, is a portrait artist. She finds it especially satisfying to depict the people of the area against the background of the local landscape which she loves. Her commissioned oil paintings hang in public and private settings in a number of states.

Java 8 launched today and it’s a groundbreaking release since Java 1.2. Although Java 5 brings big features but Java 8, as a whole, is really an enormous step for the Java language and platform.



Java 8 is the first truly revolutionary release we’ve done in a very long time



- Mark Reinhold (chief architect of the Java Platform)



Formal support of Lambda expressions, the Stream API and Functional Interfaces are spectacular improvements to java platform that allows developers to take advantage of multicore processors. Other than that new Date Time API, new JavaScript Engine, Compact Profiling, annotations and concurrency enhancements are impressive improvements.


Java 8

Java 8 Features



Language and Platform Features




  • Lambda Expressions


    Aka closures, enable developers to encapsulate a single unit of behavior and pass it to other code. Its like syntactic sugar for an anonymous class (with one method whose type is inferred) and is an object-less method or anonymous method. Its the most dominant feature of Java 8 and will have great implications for simplifying development. Behind the seen it is not an anonymous class; it actually uses invokedynamic in the byte-code.




  • Stream & Bulk Data Operations


    Represents a sequence of objects, somewhat like the Iterator. However, unlike the Iterator, it supports parallel execution. Classes in the new java.util.stream package provide a Stream API to support functional-style operations on streams of elements. The Stream API is integrated into the Collections API, which enables bulk operations on collections, such as sequential or parallel map-reduce transformations.




  • Functional Interface


    Its defined as an interface with exactly one (non default) method. This concept also applicable to interfaces that were created with earlier Java version. Java 8 comes with several functional interfaces in package,java.util.function.




  • Method Reference


    As its title are reference to some method. Java 8 allow developers to refer any existing method  or anonymous method (Lambda) as well. Method references can point to static methods, instance methods, particular object/instance methods and constructors.




  • Default Method


    Aka Defender Methods or Virtual Extension methods, now adds support for multiple inheritance in java(multiple inheritance of implementation more precisely). It help API authors to add new methods to an interface without breaking the old code that already using the actual interface.




  • Type Annotations


    (Annotations on Types) extends the set of annotatable locations, now developers are allowed to use annotations along with the use of a type. This new ability is primarily aimed at supporting type-checking frameworks that refine Java’s built-in type system.




  • Repeating Annotations


    These  provide the ability to apply the same annotation type more than once to the same declaration or type use. Improve the readability of source code which logically applies multiple instances of the same annotation type to a given program element.




  • Generalized Target-Type Inference


    It expands the scope of method type-inference to support (1) inference in method context and (2) inference in chained calls. Now developers need not to manually specify type-parameters on chained callas, method call in some expressions.




  • Method parameter reflection


    provide a mechanism to easily and reliably retrieve the parameter names of methods and constructors at runtime via core reflection. It allow to improve IDE capabilities by making parameter names more widely available.




  • New Date/Time API


    is thread-safe, easier to read, and more comprehensive than the previous API. It will make developers more productive, whether they are using the global date and time standards or one of the regional calendars.




  • Base64


    encoding/decoding provides a standard built-in API for encoding/decoding resources. URL Base64 Encoder provides an encoding that is URL and Filename safe.




  • Compact Profiles & Small VM


    allow developers to use just a customized subset of the platform, and is a major step toward the merging of Java SE and Java ME. It opens horizons to work on the smallest embedded Internet of Things (IoT) devices to enterprise servers in the cloud. Small VM feature support the creation of a small VM that is no larger than 3MB.




  • Nashorn


    replaces Rhino as the default JavaScript engine and intend to provide a version of JavaScript that would run as part of JVM. The new script engine allow to import packages, use and even extend Java classes inside JavaScript,  and invoke JavaScript functions directly from Java as well.




  • PermGen


    removed from the Hotspot JVM. Class meta-data in native memory and move interned Strings and class statics to the Java heap. The code for the permanent generation in the Hotspot JVM will be removed.




  • JavaFX 8


    is now available for ARM platforms. JavaFX is now integrated in Java SE, developers can use the java command-line launches JavaFX applications. It also allow developers to embed Swing content into JavaFX applications.




  • Miscellaneous


    There are many other new concepts and improvements in the platform like Concurrency  API improvements, preparation for modularization (Jigsaw), Statically-Linked JNI Libraries, Parallel Array Sorting, Internationalization improvements,  JDBC-ODBC Bridge removal, addition of new tools, enhancements in some existing tools  and many more.




  • Backports


    for some of these exciting features are available in market. If due to some reason application can’t immediately be upgraded to Java 8, developers can still spice their code with these exciting features to previous versions of Java. For each of the following features, here is the backport or similar library:





Source : http://zishanbilal.com/

Java 8 launched today and it’s a groundbreaking release since Java 1.2. Although Java 5 brings big features but Java 8, as a whole, is really an enormous step for the Java language and platform.



Java 8 is the first truly revolutionary release we’ve done in a very long time



- Mark Reinhold (chief architect of the Java Platform)



Formal support of Lambda expressions, the Stream API and Functional Interfaces are spectacular improvements to java platform that allows developers to take advantage of multicore processors. Other than that new Date Time API, new JavaScript Engine, Compact Profiling, annotations and concurrency enhancements are impressive improvements.


Java 8

Java 8 Features



Language and Platform Features




  • Lambda Expressions


    Aka closures, enable developers to encapsulate a single unit of behavior and pass it to other code. Its like syntactic sugar for an anonymous class (with one method whose type is inferred) and is an object-less method or anonymous method. Its the most dominant feature of Java 8 and will have great implications for simplifying development. Behind the seen it is not an anonymous class; it actually uses invokedynamic in the byte-code.




  • Stream & Bulk Data Operations


    Represents a sequence of objects, somewhat like the Iterator. However, unlike the Iterator, it supports parallel execution. Classes in the new java.util.stream package provide a Stream API to support functional-style operations on streams of elements. The Stream API is integrated into the Collections API, which enables bulk operations on collections, such as sequential or parallel map-reduce transformations.




  • Functional Interface


    Its defined as an interface with exactly one (non default) method. This concept also applicable to interfaces that were created with earlier Java version. Java 8 comes with several functional interfaces in package,java.util.function.




  • Method Reference


    As its title are reference to some method. Java 8 allow developers to refer any existing method  or anonymous method (Lambda) as well. Method references can point to static methods, instance methods, particular object/instance methods and constructors.




  • Default Method


    Aka Defender Methods or Virtual Extension methods, now adds support for multiple inheritance in java(multiple inheritance of implementation more precisely). It help API authors to add new methods to an interface without breaking the old code that already using the actual interface.




  • Type Annotations


    (Annotations on Types) extends the set of annotatable locations, now developers are allowed to use annotations along with the use of a type. This new ability is primarily aimed at supporting type-checking frameworks that refine Java’s built-in type system.




  • Repeating Annotations


    These  provide the ability to apply the same annotation type more than once to the same declaration or type use. Improve the readability of source code which logically applies multiple instances of the same annotation type to a given program element.




  • Generalized Target-Type Inference


    It expands the scope of method type-inference to support (1) inference in method context and (2) inference in chained calls. Now developers need not to manually specify type-parameters on chained callas, method call in some expressions.




  • Method parameter reflection


    provide a mechanism to easily and reliably retrieve the parameter names of methods and constructors at runtime via core reflection. It allow to improve IDE capabilities by making parameter names more widely available.




  • New Date/Time API


    is thread-safe, easier to read, and more comprehensive than the previous API. It will make developers more productive, whether they are using the global date and time standards or one of the regional calendars.




  • Base64


    encoding/decoding provides a standard built-in API for encoding/decoding resources. URL Base64 Encoder provides an encoding that is URL and Filename safe.




  • Compact Profiles & Small VM


    allow developers to use just a customized subset of the platform, and is a major step toward the merging of Java SE and Java ME. It opens horizons to work on the smallest embedded Internet of Things (IoT) devices to enterprise servers in the cloud. Small VM feature support the creation of a small VM that is no larger than 3MB.




  • Nashorn


    replaces Rhino as the default JavaScript engine and intend to provide a version of JavaScript that would run as part of JVM. The new script engine allow to import packages, use and even extend Java classes inside JavaScript,  and invoke JavaScript functions directly from Java as well.




  • PermGen


    removed from the Hotspot JVM. Class meta-data in native memory and move interned Strings and class statics to the Java heap. The code for the permanent generation in the Hotspot JVM will be removed.




  • JavaFX 8


    is now available for ARM platforms. JavaFX is now integrated in Java SE, developers can use the java command-line launches JavaFX applications. It also allow developers to embed Swing content into JavaFX applications.




  • Miscellaneous


    There are many other new concepts and improvements in the platform like Concurrency  API improvements, preparation for modularization (Jigsaw), Statically-Linked JNI Libraries, Parallel Array Sorting, Internationalization improvements,  JDBC-ODBC Bridge removal, addition of new tools, enhancements in some existing tools  and many more.




  • Backports


    for some of these exciting features are available in market. If due to some reason application can’t immediately be upgraded to Java 8, developers can still spice their code with these exciting features to previous versions of Java. For each of the following features, here is the backport or similar library:





Source : http://zishanbilal.com/