Java Testing with Spock: A good (and sometimes Groovy) guide to using this powerful testing framework – #programming #java

Java Testing with Spock

Konstantinos Kapelonis

Manning, paperback

 

Spock, the author states, is “a comprehensive testing framework for Java (and Groovy) code that can help you automate the boring, repetitive, and manual process of testing a software application. Spock is comprehensive because it’s a union of existing testing libraries”—specifically JUnit, Mockito and JBehave. It also is influenced by several others.

What is Spock’s main advantage in test scenarios? “When things go wrong,” Konstantinos Kapelonis notes, “Spock gives as much detail as possible on the inner workings of the code at the time of the failure.”

Spock is written in Groovy, and just mentioning that language, as well as the Gradle build tool, may give a little heartburn to hardcore Java developers who don’t want to learn them. But others find Groovy refreshingly efficient and Gradle easy to use. In any case, using Groovy (and Gradle) with this book is “optional,” the author emphasizes. As noted in Appendix A, “It’s perfectly possible to use Spock in your Java project without installing Groovy itself.”

To emphasize that point, Kapelonis shows how to use Spock with the Maven build tool first, before he delves into how to use Spock with the Gradle build tool.

The book is divided into three major parts: (1) Foundations and brief tour of Spock; (2) Structuring Spock tests; and (3) Spock in the Enterprise.

Two appendices deal with installing and using Spock, plus getting your IDE set up, and using the book’s example files.

Java Testing with Spock is a comprehensive guide to learning how to do Java (and Groovy) testing with Spock, and it is generally well written and adequately illustrated.

I chose to try the Groovy-Gradle approach, with Eclipse as my IDE. And I did run into some awkward moments trying to get Eclipse Mars.2 to play correctly. The Groovy-Gradle plug-in from the Eclipse Marketplace was for earlier versions of Eclipse, and so was the Spock plug-in. After some tinkering and reconfiguring, I was able to get things working together and do some Java and Groovy tests. To be fair, I was doing this on a kludged-together Windows 10 machine that definitely is no development powerhouse. And I did not have time to try out the Maven approach, but I have used Maven in the past, and the author’s instructions and examples for Maven look solid.

Java Testing with Spock is a good, helpful how-to book for anyone who wants to know more about putting the Spock testing framework to good use at all levels of Java development.

Si Dunn

Advertisements

‘Spring Boot in Action’ can help you push aside the old drudgeries of configuring Spring applications – #programming #bookreview

Spring in Action

Craig Walls

Manningpaperback

If you have worked with the decade-old Spring framework, you know well that it has a long history of providing configuration headaches for developers. The new Spring Boot framework, on the other hand, literally brings much-needed simplification and automation to the process of using Spring. And it can put some refreshing fun back into application development.

“Spring Boot,” Craig Walls states in his new book, “is an exciting new way to develop Spring applications with minimal friction from the framework itself. Auto-configuration eliminates much of the boilerplate configuration that infests traditional Spring applications. Spring Boot starters enable you to specify build dependencies by what they offer rather than use explicit library names and version. The Spring Boot CLI takes Spring Boot’s frictionless development model to a whole new level by enabling quick and easy development with Groovy from the command line. And the [Spring Boot] Actuator lets you look inside your running application to see what and how Spring Boot has done.”

You do not need a lot of Spring experience to benefit from this book. You do need some Java background, and it is helpful to have used Groovy, Gradle and Maven a few times. But the book’s text is written smoothly, and it is well illustrated, with numerous code examples and a few screen shoots. So Java developers who are fairly new likely can use it and pick up new skills.

While going through the book, you develop a reading-list application using Spring Initializr, Spring Boot, Spring Tool Suite, and other tools. In the project, you “use Spring MVC to handle web requests, Thymeleaf to define web views, and Spring Data JPA to persist the reading selections to a database,” Craig Walls explains. Initially, at least, “an embedded H2 database” is employed during development.

Walls’s book is divided into eight chapters:

1. Bootstarting Spring
2. Developing your first Spring Boot Application
3. Customizing configuration
4. Testing with Spring Boot
5. Getting Groovy with the Spring Boot CLI
6. Applying Grails in Spring Boot
7. Taking a peek inside the Actuator
8. Deploying Spring Boot applications

Four appendices also are presented: Spring Boot developer tools, Spring Boot starters, Configuration properties, and Spring Boot dependencies.

Bottom line: with Spring Boot providing much of the heavy lifting, you likely will gain better feelings about the venerable Spring framework. You may even wind up with a healthy new respect for it. And Spring Boot certainly should add more years to Spring’s usefulness and viability in the marketplace.

Si Dunn

Ionic in Action – A solid guide to building hybrid mobile apps with Ionic and AngularJS – #programming #bookreview

Ionic in Action

Hybrid Mobile Apps with Ionic and AngularJS

Jeremy Wilken

(Manning, paperback)

Ionic in Action is a very good introduction to the Ionic framework, which the author describes as “a combination of tools and utilities….” These tools and utilities enable developers “to quickly build hybrid mobile apps using the same technology used to build websites and web applications, primarily HTML, CSS (Cascading Style Sheets) and JavaScript.” Using Ionic, you build “hybrid mobile apps,” which employ a browser window to display the user interface.

Ionic in Action shows how build three different mobile web apps. And, while working on those apps, you encounter virtually every feature that Ionic offers. I recently started learning Ionic, so I am pleased with how this book is organized and impressed that it has some important blessings from Adam Bradley, a co-creator of the Ionic framework.

Ionic is built on top of AngularJS, and it interacts with Cordova. The author of Ionic in Action, Jeremy Wilken, promises that being familiar with AngularJS is “helpful but not required.” However, as someone who has wrestled with AngularJS (and been slammed to the scope mat more than once), I am pleased that this book includes a chapter titled “What you need to know about AngularJS.” And, as in the rest of the book, you learn by doing, not just by reading explanations and looking at illustrations.

In the Angular chapter, you build a basic web application using AngularJS. Of course, one chapter does not take the place of a good AngularJS tutorial. But it provides a useful starting point.

Whether you are working to become a mobile app developer or seeking to improve and widen some existing skills, this is a good book both to learn from and keep handy in your reference library.

Si Dunn

‘Meteor in Action’: A good how-to guide for learning a popular JavaScript framework – #programming #bookreview

 

Meteor in Action

Stephan Hochhaus and Manuel Schoebel

Manning – paperback

I have worked with several JavaScript frameworks, and Meteor has become a favorite, mainly because it is closely related to the MEAN stack family and plays well with MongoDB and Node.js.

As the Meteor in Action authors note: “Meteor runs on top of Node.js and moves the application logic to the browser, which is often referred to as single-page applications. The same language is used across the entire stack, which makes Meteor an isomorphic platform. As a result, the same JavaScript code can be used on the server, the client, and even in the database.”

Meteor is versatile and easy to use, particularly for simple applications. But, like any other JS framework, it does have a learning curve. And there are some inherent weaknesses, as well as strengths, that must be considered when deciding if Meteor is the right choice for a particular project.

Meteor in Action can give you a good grounding in Meteor’s basics, plus solid momentum along the path toward Meteor mastery. The book begins with a polished and not-too-lengthy overview of Meteor’s Open Source framework. Then it shows how to build a small, reactive game application. From there, the major topics include: templates; data; fully reactive editing; users, authentications, and permissions; exchanging data; routing; the package system; advanced server methods; building and debugging; and going into production.

Another reviewer has stated that parts of this book may be outdated soon, because some of the technology associated with Meteor is changing fast. But not every work site immediately will keep up with the latest and “greatest” changes to Meteor software, of course. And, you may encounter applications needing support that are still running earlier releases of Meteor.

This  is a worthy and valuable book for anyone just starting to learn Meteor. And it likewise can be helpful to Meteor users who want better understanding of the framework, how it is put together, and how it can be used effectively in large applications. The two authors of this book have been working with Meteor since the framework’s “infancy” in 2011.

Si Dunn

 

 

 

Unity in Action: A top-notch how-to guide for game developers – #gamedev #programming

Unity in Action

Joseph Hocking

Manning – paperback

Unity, the cross-platform game development environment, is easy to download and get running. But it definitely is not easy to learn without some help.

Fortunately, Joe Hocking’s Unity in Action makes it reasonably straightforward to learn how to develop games in 3D, as well as with Unity’s new 2D capabilities. The book takes the reader from “Hello, World” all the way to “Putting the parts together into a complete game” and then “Deploying your game to players’ devices.”

Even with this fine book, however, game development can be hard and complicated work. There are many different elements to consider, such as “Adding enemies and projectiles to the 3D game”, “Developing graphics for your game”, “Adding interactive devices and items within the game,” and putting sound effects and music into your game. Hocking’s book does a good job of showing how to handle these tasks, plus many more.

You may have heard Unity described as a game development environment where you don’t have to know how to program. Yes, you might be able to create some games without programming skills. But, “to produce commercial titles” using Unity, you definitely need some programming experience, Hocking emphasizes. In this case, you should have some knowledge of C#, but a background in some other object-oriented (OO) programming language will be helpful if you are new to C#, he adds.

Hocking’s book has many examples, illustrations, headings and subheadings. But step-by-step listings are sparse. Therefore, be prepared to read the text closely and, if necessary, develop lists of steps yourself. There is nothing wrong with this approach, and it is not really a criticism of the book. Game development, after all, is not something that you can, nor should, just dive into and speed through, step by step. It requires a lot of careful planning and thought before you start.

Unity in Action wastes no time. It gets right to the essential stuff you need to know. And it can get you into action reasonably fast as a game developer. But “reasonably fast” in this case must be defined by how quickly you personally can learn to handle Unity, plus the myriad tasks of planning, creating, testing, revising and distributing a game.

Si Dunn

 

Elixir in Action: A good guide to the ‘alternative language for the Erlang virtual machine’ – #programming #bookreview

 

 

Elixir in Action

Saša Jurić

Manning – paperback

“Elixir,”  Saša Jurić writes, “is a modern functional programming language for building large-scale, distributed, fault-tolerant systems for the Erlang virtual machine.”

What Elixir really is, of course, is a breath of fresh air for software developers who find it hard or confusing to work with Erlang’s sometimes complicated syntax and conventions.

Erlang has long been almost off the chart–the bottom of the chart–when computer languages are stacked up by popularity.  It began its oddball life in the 1980s as a programming language for the computers in telephone switching systems, specifically Swedish-made, Ericsson telephone switching systems.

Indeed, I first encountered Erlang in the  late 1980s while trying to help Ericsson sell Swedish-made computers to American banks. Back then, I counted my lucky stars that I didn’t have to learn it, because I was a tech writer, not a software developer.

Today, however, Erlang and its Open Telecom Platform (OTP) libraries are gaining new converts among serious practitioners of functional programming. Many of them likewise are drawn to Erlang’s built-in support for concurrency, distribution and fault tolerance.

The digital Swedish meatball known as Erlang turns out to be a powerful choice for providing high reliability and scalability to networked and distributed systems with multi-core processors. Telephone networks require high reliability and flexible scalability. And Erlang was designed to help provide both — without limiting itself to telecom systems.

Some of Erlang’s lack of popularity can be blamed on the language’s somewhat difficult learning curve. But it also has not been heavily promoted to software developers. That has been changing recently as companies and developers learn more about Erlang’s good track record, Saša Jurić points out.

“It powers various large systems and has been doing so for more than two decades, such as the WhatsApp messaging application, the Riak distributed database, the Heroku cloud, the Chef deployment automation system, the RabbitMQ message queue, financial systems, and multiplayer backends. It’s truly a proven technology.”

In Elixir in Action,  Saša Jurić nicely meets his goal of writing a book that brings “programmers new to Elixir and Erlang to the point where they can develop complex systems on their own.” Elixir provides an alternative language based on several other languages, including Ruby and Clojure, as well as Erlang.

Jurić’s how-to guide requires no prior experience with either Erlang or Elixir, but you should be familiar with at least one other programming language, such as JavaScript, C# or Ruby.

His book is divided into three parts:

  • Part 1, “The Language,” offers a high-level overview of Erlang and Elixir. Then it delves into Elixir’s basic building blocks and details common functional programming idioms.
  • Part 2, “The Platform,” focuses on primary aspects of BEAM, the Erlang virtual machine, as well as “how concurrency works and how it can help you build reliable systems.” Indeed, “[c]oncurrency is at the heart and soul of Erlang systems,” Jurić writes. “Almost every nontrivial Erlang-based production system is highly concurrent. Even the programming language is sometimes called a concurrency-oriented language.”
  • Part 3, “Production,”discusses “production aspects of BEAM-powered systems,” as well as “how to package components, reuse third-party libraries, and build a simple web server,” and “how to build a deployable standalone release and how to interact with the running system.”

Elixir in Action does not cover everything. But it provides fine overviews, clear how-to instructions, and compact code examples that illustrate important points. It can get you going in good directions.

“Elixir,” the author emphasizes, “lowers the entry barrier into the Erlang world and improves developer productivity.”

 — Si Dunn

 

Groovy in Action, Second Edition – A hefty how-to guide newly updated for Groovy 2.4 – #programming #bookreview

Groovy in Action, Second Edition

Dierik König and Paul King, with Guillaume Laforge, Hamlet D’Arcy,
Cédric Champeau, Eric Pragt and Jon Skeet

Manning – paperback

Groovy in Action, Second Edition, is not light reading. Indeed, the printed book weighs nearly three and a half pounds and has 880 pages. But it is great reading for anyone who wants to learn, or get better at, the increasingly popular Groovy scripting language that works very smoothly with Java. Indeed, Java’s creator, James Gosling, has hailed Groovy’s “smooth and efficient” integration with Java and called Groovy “an effective implementation language in its own right.” He also has praised the Groovy in Action book as “a clear and detailed exposition of what is groovy about Groovy.”

The Second Edition‘s two main authors and five assisting authors are members of the Groovy core team. And their book spent a lot of time being reviewed and tested by readers in the Manning Early Access Program (MEAP) before it was formally released. So it likely has a better preparation record than many programming books currently on the market.

Groovy in Action‘s front flap indicates that the book covers Groovy 2.4. Groovy recently was up to version 2.4.3, but the programming language has maintained a good track record for supporting backward compatibility. Indeed, I tested random selections of the book’s code samples using version 2.2.0 and its Groovy Console, and programs compiled and ran without problem.

However, if you own the first edition of Groovy in Action, you likely will want to upgrade to the new book. It is, the authors state, “a full rewrite,” with several new chapters, plus  “a few hundred additional pages of genuinely new content.” (And yes, I am upgrading my Groovy installation from 2.2.0 to 2.4.3.)

Despite its heft, the book is nicely structured and easily approached. And its many code examples are mercifully compact, for the most part, and available online, if you prefer. (I actually enjoy keying reasonably short code examples into the Groovy Console.)

The 20 chapters are organized into three major parts:

  • The Groovy Language
  • Around the Groovy Library
  • Applied Groovy

“The Groovy Language” introduces the reader to the language’s basics: its “syntax, grammar, and typical idioms,” plus how to use dynamically typed Groovy as a static language, if desired. The “Around the Groovy Library” reference section focuses on such topics as working with builders and the Groovy Development Kit (GDK), as well as Groovy’s support for database programming and the handling of JSON and XML. And “Applied Groovy” looks at “typical uses cases for Groovy,” including “a thorough exposition of how to use Groovy for test automation,” how to put Groovy to work on multi-core machines in concurrent programming situations, and “using Groovy for domain specific languages.”

In short, there is no shortage of useful content in Groovy in Action, Second Edition.

Si Dunn

——————–
Get Groovy in Action, Second Edition here, at no extra cost.
——————–