Test and Data Generation for Java Unit tests

Today I was preparing a presentation about Software Code quality for a TechTalk on Thursday. I made a search on Internet about Automatic Unit test generator and Data Generators. I will present some tools I have tried. Today, we will speak of Randoop.

Randoom Test Generator

Randoom Test Generator

The first tool name is Randoop.. This tool is existing since 2007 and its purpose is to generate automatically unit tests đŸ™‚ Directly from your class definition!

To use it you have two choices:

  • You can use your software JAR or classpath directory.
  • You can include it in your test compile path (on gradle or maven) and creates a main or unit test.

To explain short the theory, thanks to the Java reflection it’s quite easy to produce automatic tests validating some contracts of your API.

Some examples: – toString() should never returns null or throws an Exception – equals() and compareTo() methods have a long list of constraints – Reflexivity: o.equals(o) == true – Symmetry: o1.equals(o2) == o2.equals(o1) – Transitivity: o1.equals(o2) && o2.equals(o3) ⇒ o1.equals(o3) – Equals to null: o.equals(null) == false – It does not throw an exception

Therefore this tool is generating unit tests with JUnit(TestSuite) for the list of classes you provide.

I have done some tests and you can reach 50-60% of coverage quite easily.

The main drawbacks of the solution are: – The unit tests are drawing a snapshot (precise picture) of your code and its behaviour however some tests are really non-sense and you don’t want to edit them. – They don’t replace handwritten tests since the tool is not understand the different between a String parameter emailand fullName. He will mostly use dumb strings.

About the technology, it’s not production ready: – I had troubles with the jar and its dependency plume. – The JAR is a fatjar and coming with dependencies that broke my software.

In conclusion, I will fork the software and try to fix the problems to make it more popular đŸ™‚


How I switched my blog from OVH to Google Container Engine

In this short story, I will relate how I migrate my blog personal website from a classic VM instance to Google cloud using Kubernetes, Docker, Nginx.

Onoe of my personal goal was also to have a cloud deployed website without spending any money.


Long story made short, I have been using Docker on several projects since one year. I progressively got accustomed with the ease of deployment provided by Docker. The issue ? The day I have launched my blog (on February 2017),for time and cost reasons, I picked an VPS instance from OVH.

Why OVH ? Clearly it is one of the cheapest IAAS provider and quite popular there in France. I have been using it for several projects without any major issues.

OVH has an offer of public cloud OVH Public cloud. However the offer looked immature at that time both in documentation than on reviews. The second reason of my rejection is about cloud adotpion. A lot of experts are turned toward GCloud and AWS. Spending my efforts on OVH would not provide enough visibility at short term, in my job.

To better accompany my colleagues and customers to adopt the cloud , I have decided to eat my own dog food. And among my personal projects, I have decided to migrate first my blog.

And to switch my blog from OVH to Google Cloud (Container Engine).


Here are some interesting articles about pricing and functionalities for the major cloud providers :

Technical situation

My blog is hosted on a VPS server (shared instance on OVH). I have installed on it, Apache 2, some monitoring and security system and Let’s encrypt to obtain a free SSL certificate.

Hexo command line

Hexo command line

My blog is not using the classifical wordpress, I am quite fond of static website generators and more recently of flat/headless CMS.

I am using HexoJS as a CMS. Main features are you are writing your article in Markdown and the blog has to be regenerated to produce the static files, producing quite optimized pages.

Hexo command line

Hexo command line

How to switch from a legacy deployment to the cloud.

These are the explanations how I proceed to migrate this website.

 A) Create my Google Cloud Account

Yes, we have to start from the beginning and I created a new Google Cloud Account. Though it is rather easy to create its account, I have been surprised. It was impossible to for me to pick an individual account.

It’s even in the Google FAQ (FAQ).

{% blockquote By Google FAQ %} I’m located in Europe and would like to try out Google Cloud Platform. Why can’t I select an Individual account when registering? {% endblockquote %}

The reason (thanks EU.. ) is dumb as fuck : In the European Union, Google Cloud Platform services can be used for business purposes only

For information, in Switzerland, the limit is lifted.

Interesting enough, the free trial on Google Cloud has been expanded to 300$ for one year.

B) Discover Google Cloud

Well the UI is easy to manipulate even with this nagging collapsing menu on the right side.

Google Cloud Console

Google Cloud Console

The documentation is quite abundant but I found two major issues :

  • Lack of pictures and schema : most concepts are described with a bunch of words. Fortunately, some very kind people made great presentations (here and here).
  • Copy/Paste from the Kubernetes website : yeah most of the documentation can be found on Kubernetes, logically.
  • Lack of informations and use cases : for some examples as using this damn Ingress. Why people are not providing Gist đŸ™‚

I created a cluster with two VM instances, 0.6GB of RAM and 1 core. Indeed I wanted to play with the load balancing features of Kubernetes.

Create a cluster

Create a cluster

C) Replicate my server configuration as a Docker container

The easiest and funniest part has been to reproduce my server configuration with Docker and to include an evolution. I wanted to switch from Apache 2 to Nginx.

First solution I created. I used a ready-made (and optimized) container image for Nginx and modified my build script to generate the Docker image. The generated website is already integrated into the Docker image.

FROM bringnow/nginx-letsencrypt:latest

RUN mkdir -p /data/nginx/cache
COPY docker/nginx/nginx.conf /etc/nginx/nginx.conf
COPY docker/letsencrypt /etc/letsencrypt
COPY docker/nginx/dhparam /etc/nginx/dhparam
COPY public /etc/nginx/html

I made several tests using the command docker run to check the configuration on my own machine.

docker run --rm -i -t us.gcr.io/sylvainleroy-blog/blog:latest -name nginx

D) How to host my Docker image ?

My second question has been how to store my Docker container ?

Creating my own registry ? Using a Cloud Registry ?

I have used two different container registries in my tests.

First is the Docker Hub.

Docker Hub

Docker Hub

What I appreciate the most with the Docker Hub, is that I can delegate the creation of my Docker images to the Hub by triggering a build from GitHub. The mechanism is quite simple to enable and really convenient. Each modification of my DockerFile is triggering a build to create automatically my Docker image!

Here is a small draw to explain it :

Docker Hub & Builds draw

Docker Hub & Builds draw

And some part of the configuration.

Docker Builds Configuration

However Google Cloud is also offering a container engine and its usage has been redundant. I kept it to use it with CircleCI.

Therefore for the time being, I am storing my Docker container on Google Cloud.

Google Cloud Container Registry

Google Cloud Container Registry

With this kind of command :

gcloud docker -- push us.gcr.io/sylvainleroy-blog/blog:0.1

E) The Cloud migration in itself

Maybe it is one my fancy side, but I have only used the GCloud CLI to perform the operations.

Install Google SDK

Everything go smoothly but don’t forget to install Kubernetes CLI.

gcloud components install kubectl

I had a problem with the CLI. It could not see my new projects (only some part of them) and I had to auth again.

gcloud auth login

And perform a new login to see the update.

Don’t forget to also add your cluster credentials using the GUI instructions (button connect near each cluster).

Google Cluster

Google Cluster

gcloud container clusters get-credentials --zone us-central1-a blog

 Understanding the concepts of Pod, deployment

It took me time to understand what is a deployment and a pod. Using docker and docker-compose I could not attach the concepts.

That is one of my concerns with Kubernetes, some technical terms are poor and does not really help to understand what is behind.

Well, I finally create a deployment, to create two docker instances inside my pod (replica=2). This deployment file is declaring basically that it requires my previous Docker imamge and that I want two copies. The selector and the label mechanism is quite handy.

apiVersion: extensions/v1beta1
kind: Deployment
  name: blog-deployment
  replicas: 3
        app: nginx
        role: master
        tier: frontend
      - name: nginx
        image: us.gcr.io/blog/blog:0.9
          - containerPort: 80
            name: http
          - containerPort: 443
            name: https 

I use such commands to create it :

̀€kubectl create -f pod-blog.yml

KubeCtl Pod informations

KubeCtl Pod informations

 Automating the generation, docker image building and deployment

I have automated the full cycle of my site generation, docker building and container registry and pod reload using CircleCI.

CircleCI Deployment Schema

CircleCI Deployment Schema

And the good thing is that all these things are free.


After playing during two weeks with it on my spare time, I have the following feedback :

 Rolling Update

The deployment mechanism and how the rolling update is performed are impressive and a time-saver.. Some banks are still using an manual way or semi-automated way like Ansible to deploy their software and the rolling updates are performed awkwardly. Here Kubernetes is deploying on the background the new version, controlling its state (roughly) and if the conditions are met, switching from the old version to the new version. I am using this mechanism to bench my Docker new images and push the new versions.

 Load Balancing mess

I had to struggle a lot to set up my load balancer. Well, not at begin. Kubernetes and GCloud are describing precisely how to set-up a Level-4 LoadBalancer. It takes few lines of YAML and it was fine. However, I had huge difficulties when I decided to switch to TLS and my HTTPS Connection with Let’s encrypt.

I met several difficulties :

  • How to register my SSL certificate on a Docker container tough not deployed ?
  • What the fuck is a NodePort ? The difference with ClusterIP and a LoadBalancer and an Ingress ?


  • Where should I store my certificate ? in the GCloud configuration or in my NGINX ?
  • Why Ingress is not working with multiple routes ?

To address the following issues, I found the temporary solutions :

  • I am using Certbot/Let’s Encrypt certification using DNS. That way, I can generate my certificates "offline".
  • I am not sure about the definition of what is a NodePort, either I need a LoadBalancer for a single container in my pod or simply open the firewall. These concepts, introduced with Kubernetes are still obscure for me, even after several reading.
  • I took the decision to implement my HTTPS LoadBalancing by modifying my NGINX configuration to store the certificate and rely on a Level 4 LoadBalancer to dispatch the flow.
  • I tried really hard to make Ingress working (the level-7 LB) but even the examples where not working for me (impossible to map the port number 0 error) and really bad documented.

 Persistent volume

The documentation about persistent volumes is not precise in Kubernetes and GCLoud and have important differences between the implementation and Google and even between versions.

You have many possibilities :

  • Use a Persistent Volume, PersistentClaim and attach them to your containers
  • Generating directly a volume from your deployment file

Another issue I have met, my docker container was failing (and the pod itself) because the persistent volume created is never formated.

But why ????

Indeed in your deployment file, you have properties to set the required partition format. But no formating will be performed.

And therefore I had the following next issues :

  • How to mount something unformated ?
  • How to mount something unformated in a container of the pod without using the deployment ?
  • Why is there so few documentation in Google Container Engine (in comparison with Google Compute Engine) ?

The recommended solution is to create an VM instance by HAND using Google Compute Engine, to mount attach the disk to the instance. To mount it manually and trigger the formatting. WTF

If you have a better way to handle the issue, I am really interested!


After a month of deployment, I haven’t spend a buck. My page response time decreased from 3.4s to 2.56s And I am not waking up during the night, the eyes full of horror thinking about how to reinstall the site. I only have a container to push.

I am not using yet the Kubernetes UI and I don’t see yet the necessity. The CLI offers almost everything.

Cleaning a cluster, the pods and deployments requires several steps and maybe could be simplified.


One very important aspect of my project was also to decrease the bill to host the site.

Currently, here is my bill for 1600 visits per month :

  • I have a GitHub private repository (~7$/month)
  • I am using the free tier of CircleCI offering me the usage of a Private GITHub repository and important number of build
  • Docker Hub is free for any number of public repositories and 1 private docker repository.
  • I am using the free tier of Google and I spent 1$ in one month and the bill is shared between my blog and my other projects.
  • I have a cluster of 2 VM for my blog

Compared to my 79€/year for my VPS.

Interesting links


How Docker is disrupting Legacy IT Companies

Thanks to its popularity, Docker has disrupted many companies and blurred the silos between Developers and Operations. In this article, based partially on my own experiences, I will depict some of the disruptions that containers have provoked into the IT companies. I wish that this article will depict familiar situations and brings you argument to win the obstacles to the container technology propagation đŸ™‚

Disclaimer : Despite I am quoting Docker quite a lot in this article, it is not an endorsed article. If you have a better alternative, simply replace Docker by another Container Technology, the arguments should still be valid.

If you appreciate this article, please relay or like it.

 Day one : I don’t need to spend four hours to setup my development environment

That is my first day on the job. A brand-new laptop, decent performance and feature. Default Operating system : Windows.

Well, I am a Linux hardcore developer and I spent many efforts to live without Excel, PowerPoint and Outlook. And who knows ? Maybe my customers won’t be on Windows. Therefore, I am wondering how to create my new software development environments ? Node.JS ? Java ? Mobile, each technology is coming with their own tools, servers and configuration.

What are the choices ? The company is fair and provides a decent laptop with sufficient power. However the software installation on the native OS has been blocked. I need to proceed by virtual machines. Virtual machines ? What a cumbersome solution. I need to download ISO or OVA’s and proceed to the installation of my software. What is your virtual machine creation’s strategy ? I made a quick survey to my colleagues, who confirm that they create a virtual machine by customer’s project. And they share their virtual machine like Pokemon. WTF ? Many dozen of gigabytes are transferred through USB3, a tiny hard drive and the team is ready. Well after several hours.

Docker or any similar container technology is offering me a better solution.

These are the following arguments :

  • Reduce your startup time and be more efficient. You can find many docker images to set up a development environment ready to use :

  • Docker image node.js dev : A Dev environment for JS
  • Docker image Ruby Dev, Docker image Ruby Dev2
  • Docker image C/C++ on Linux
  • Docker image Java Dev
  • Docker image PHP Dev

  • Broadcast your software programming best practices by using the same env in your team. As a tech lead, my mission is to make my colleagues better than me. And to reach that goal, I am trying to provide them the best tools, configuration, IDE, and automation to help them in their work. How many times, I had to provide a format style guideline to indent their code ? A syntax checker configuration ? An IDE with the right plugins ? All these issues can be solved by providing my docker image and updating it regularly.

  • The time for for Web IDE software is probably come : Eclipse and Visual Studio, Borland Delphi, such IDE have been used by generations of developers. They all come with the same advantages and drawbacks. Powerful, clever code completion, nice OS integration and notifications, a whole bad of features. Clearly the develop has a great environment to write its software but these solutions do not scale well inside a team. How to share my configuration ? My preferences ? How to share code ? How to communicate ? To create coziness in your team, you will have to rely on a great IT administrator. A magician of the command line, Powershell to setup your OS with the same configuration everywhere, yet able to update it regularly.

My recommendation is to rely on two kind of tools to produce your software : – lightweight code editors such like Atom, Visual Studio Code from Microsoft – Web IDE such like Cloud 9 or CodeEnvy is a great example. Using Eclipse Che, the web rewrite of Eclipse, a Saas IDE with the same lot of features and configuration. The most amazing thing is that this great and complex system can be installed with a Docker one liner.

 Day two : Security everywhere, freedom and performance nowhere

As software specialists, we are well aware of the threats coming from the web applications, unobserved operating systems, data breaches. Our daily duty is to protect our customer data.

The consequence for developers is a matter of rule, our computers are locked. Software installation is double checked by IT, Internet is accessed through a proxy, antivirus, whitelist and so on. Hard disk ciphered and so on. in ch All developments have to be done on Virtual machines. BUT Virtual machines are such a pain to manage. A huge disk space, hard to customize, fairly expensive solutions (licence cost of VMWare to be able to perform VM snapshot on every developer laptop…)

Docker Datacenter

Docker Datacenter

Building Virtual Disk images is a tremendous task for the system administrators : slow to copy, hard to customize, mostly manual installation and snapshots to produce them. Developers does not find the necessary flexibility to adapt to their customer projects.

Docker is offering a neat and efficient way to produce images, thanks to the docker script language. A good mix between automation and the traditional system administrator work of producing shell scripts.

Using Docker images is offering enough security control to system administrator, less efforts to maintain and developers can also provide easily their own images to the Security/Administrator Team for review. But how to store your Docker images. At the present time, I would recommend something like Docker Datacenter to host your company containers on premise.

Day twenty : The typical legacy IT Project

Traditional "legacy" IT Projects features : * a code base * scripts to build the software * some manual test cases * a huge and extensive installation documentation to setup : * the test environment * the production environment * perform the maintenance, the upgrade, the backup of the system * scripts to install the database schema

In practice, most IT projects enforces developers to manually install their development, test, production environments using an out of date documentation, incomplete. How the software team is performing a QA session ? Will they create a brand new test environment with fresh data in a given state and the latest produced software version ? The answer is probably no, definitively no.

Usually, IT teams are relying on a single test server, painstakingly built through the scrum sprints, on a virtual machine. Do you think that I am exaggerating ? Ask to your team, how much time do they need to recreate this environment ? And what if their snapshot is lost or damaged ?

Continuous Dockery, ElectricCloud image property

Continuous Dockery, ElectricCloud image property

Docker is providing several solutions to common IT project problems :

  • Deploying the customer application on the developer laptop : docker images are shared between developers to have access to a debug environment. Docker composer can help the software development team to build ready-to-use.

  • Initializing and populating a database for tests : another solution to execute integration tests is to rely on Docker to build an image, ready-to-use of your data. Start the container, wait the readiness , execute your integration tests and kill the container once used. Such scenario is easy to create with Docker, even with proprietary databases such like Oracle of MSSQL. This article is a good instruction to Docker and test automation.

Deterministic Test Automation

Deterministic Test Automation

  • Multiple target and environment compilation : Developers often need to test their software in different environments, browsers. Docker images also provide a solution to the complexity of a software environment.

Day forty : The void of the production environment

Recently, I have encountered a brilliant developer – although alone – maintaining a messy piece of PHP code. He was not the originator of the project, though, in charge of the project since two years. He told me that the manager offered him a virtual machine with everything on it at the begin of the project, to help him. The same one he is using on it.

Currently, he is struggling with the customer and that software. Both the customer and him have different deployment environments. And the difference of server, languages and frameworks versions is creating a huge mess.

Another project and situation. This IT team has been relying on Ansible (with Puppet it would have been the same situation), to deploy their software in the different environments. Despite the improvements thanks to the automation provided by Ansible, there is always a slight tension when launching the Ansible scripts. Maybe it’s the system entropy, the virtual machine erosion, most likely the reason is that the virtual machine has never been deleted and recreated. Anyway there are some subtile differences between the environments and probably and the Ansible deployments are sometimes failing when new features are shipped.

System erosion

System erosion

With that team, we have reached a common point of view. When should we use Ansible to deploy the software ? We should rather use Ansible to prepare the virtual machines to host Docker, open the firewall, establishing the network routes, program the monitoring and so on. And the software will be shipped as a docker image, copied by Ansible and launched.

Docker/Containers can simplify your software deployments whether you have a private cloud or regular virtual machines. Simply install the docker system on your virtual machines and change your way to ship your software, past the effort, you won’t regret it.

Day eighty : The good old mama’s Software Factory

The last situation where Docker/Containers is really brilliant is when you use Docker inside your software factory.

Docker can be used in a software factory to make your Software factory evolve from a monolithic all-usage but slow and frustrating software factory to a real platform Software Factory As A Service (If you like the term SFAAS, it’s mine đŸ™‚

The main differences between a Software Factory and a SFAAS are the following : – Product owner, Team manager are creating the new Software Factories for their projects directly through a WebUI by picking the technologies, tools they need. – Developers have the possibility to instantiate new environments to build or test the software without any interaction, paper submission and waiting for a round trip between Earth and Mars. – Integration engineers are providing new tools and environments accessible to the projects, if they wish. – Few interactions are necessary between the infrastructure and system administration teams and the software teams. It’s a win-win solution and the IT bottleneck has been removed.

Docker Software Factory : Marcel Birkner

Docker Software Factory : Marcel Birkner

I strongly recommend that Software factories built on the top of containers like these great initiative projects.


If you have read the whole article, I can only say you a Big thank you and I hope you have been able to learn one thing or two. The apparition of containers is really helping developers, ops and I wish that the IT companies fully embrace these technologies to make our profession much funnier and attractive.


Disruption in Software Quality Assessment ?

As many other markets, the SQA/ALM Market soon will meet #disruption. Domains like machine learning, deep learning and cloud computing will force it to evolve in the next few years. This article is presenting some predictions about the future of the quality tools.

Disruption in Software Quality Assessment

Disclaimer I am not a native english speaker and I am perfecting my english skills by writing these articles. If this topic interests you, please comment below or share the article to your friends. And every syntax, grammar mistakes will be fixed under your wise comments.

A new generation of Software quality tools is going to emerge. Machine Learning, Deep Learning, DevOps, Continuous Delivery, Continuous Integration, Cloud Computing, all these movements are influencing the SQA/ALM Software Editors. It has never before been so easy and cheap to produce a new static analysis tool to measure some aspects of a software. The Opensource movement and the market evolution are the direct contributors to this state. Made famous under the name of “linters”, well-known and unknown developers are creating the tools required to their activities. And the Software editors are faced to the dilemma : “Should I continue to build my own tools ? What should be my behaviour confronted with this plethoria of scanners ?”.

Until recently, Software developers were depending of the highly-specialized skills from the Quality Software Editors to detect, analyze and fix the bugs inside their softwares. And it is a big source of frustration. From both sides. Developers are usually complaining that the rules do not reflect their real needs or the complexity of their softwares. “Quality tools do not detect real problems or too late or under a trillion of false positives”. Software Editors are providing to the hungry population rule sets, standards to satisfy the crowd. A crowd much much bigger than their own forces.

I am predicting that the disruption may be coming from these directions :

  • From the open-source : soon or later, the basic needs of developers will be fulfilled by the open-source offer. Tools like PMD, Findbugs, and so on have inspired a whole generation of developers. The young developers through the Angular 2, ReactJS, Go are already educated to the benefits of Quality tools. And they are heavily relying on linters well-integrated in their CI or in their IDE (Atom, Code). Twitter, Facebook are continuously producing and releasing in opensource new tools to help the developer community. The recent examples of Flow or PrePack are helping a lot developers to increase the quality of their products.
  • From the digital technologies. The increasing level of maturity of the machine learning and deep-learning technologies should bring us shortly new kind of tools to predict bugs, predict code defects and usual developer decisions. I believe that the scientific researches from Microsoft and Google will contribute indirectly to the Software Quality tool market. This topic is unsurprisingly very discussed (here).
  • From the software development process transformation : Movements like Agile, DevOps, Continuous Integration and Deployment, ChatBots are deeply changing the way developers are collaborating. Several aspects are changing : communication (Slack, Hipchat), software building (Jenkins, Travis CI, Microsoft TSF & Azure), software deployment (containers, PAAS, Amazon AWS)… The way a product is conceived, built and deployed requires to track and measure several quality aspects. The integration effort to produce these metrics and KPI’s is tremendous and have to be adapted to each organization. Would the developers be enough satisfied with code quality or will they require higher levels metrics extracted from their development process.


Who will be the future leaders in the ALM market ? Who will be the fastest to adapt to the current technology and data disruption ? Do you have some tools that could match these descriptions ?

If that article has been useful or interesting, stay connected, I will produce new articles on that subject.

One of my future article will present Codacy, an emerging code quality platform. This platform offer to ease the quality control as soon as possible in your development process to detect the bugs early and surely. I will compare this solution with the famous market leader SonarQube.