Friday, 6 March 2015

How to learn to code Java without using a 'main' method

In the book Java For Testers, I teach Java slightly differently to make it easier to learn. Let me explain how.



When you learn Java, one of the first things you traditionally learn is how to create a 'main' method.

That makes sense right?

After all:

  • You're learning how to write applications. 
  • Applications need to be compiled. 
  • A compiled Java application needs a main method to run.

Of course, you also need to know:


And you might need to know:



jar cmf manifest.mf helloworld.jar HelloWorld.class

java -jar helloworld.jar

And if you are beginning your learning in how to program Java, then you don't even understand the code you've written to write "Hello World" to the console

System.out.println("Hello World");

I wonder why people prefer to learn scripting languages like Python and Ruby?

But, you don't have to learn all this when you start, especially not when you want to learn to write automation code rather than application code.

You could:

  • Write all your code in an IDE
  • Write JUnit @Test methods
  • Run the JUnit @Test methods from the IDE 
    • (right click on the method name and choose "Run")


That way, you can start to learn the Java programming language. And use it to "do stuff" without all the baggage.

That's why in the book Java For Testers, you learn to write all your code as JUnit @Test methods.

And of course, our evil, manipulative subtext... you'll also start your career in Java programming by learning "Test First". So you're learning TDD and you might not even realise it.

Sneaky, but, what did you expect from the people behind EvilTester.com

Java For Testers is a tutorial guide. Learn Java by writing JUnit @Test code.

Java For Testers ebook available from:



Wednesday, 4 March 2015

Java For Testers ebook now on Amazon

 Buy Java For Testers ebook on Amazon.com
Java For Testers ebook is now on Amazon. [amazon.co.uk][amazon.com]

The same book as available on leanpub.com [see announcement]

All I changed was the copyright page to reflect Compendium Developments Ltd as the publisher.

For those of you who want to publish through leanpub and want to do this (I used the epub editor in calibre to make the changes)

Amazon has a fixed price for the ebook, and you'll receive notifications of updates to the ebook if you have Amazon set up to tell you about them.

Leanpub has a more flexibile pricing structure, so you can pay more for the book (if you think it is worth more) (or less, if you're not sure). You will also receive more email updates, and the possibility of 'bonus extras' because I can use the leanpub mailing facility to let you know about new 'Java For Testers' information.

I personally, receive more money if you buy through leanpub, and have the ability to keep in touch easier, but I've added the ebook to Amazon for wider reach world wide.

Choose the platform you are most comfortable with. If you buy on Amazon, you can always sign up to our newsletter if you want email updates.

Java For Testers ebook available from: [amazon.co.uk][amazon.com][leanpub.com]



Tuesday, 3 March 2015

Java For Testers ebook Done and Released to Leanpub

Buy Java For Testers ebook on leanpub.com
At the end of February 2015 I released the 100% version of Java For Testers on leanpub.

If you ever wanted to learn how to code in Java, but found other beginner books hard to read or work through then this tutorial guide should help.

I focus on the core features of Java to help you achieve a lot, without overloading you, and I concentrate on the main language constructs and core libraries that I use when writing automation code.

Most Java books will have your writing manifest files, writing 'main' methods, and using the javac compiler from the command line. All of which adds extra complexity when you are trying to learn the basics.

With Java For Testers, you write and run all your code from the IDE. You will learn to write code test first with 'JUnit @Test' methods, and you'll run them from the IDE. This makes learning a lot easier.

Most Java books will have you writing Swing or JavaFX GUIs. You won't learn that in Java For Testers, because you won't need it. The IDE or the Continuous Integration system will be the GUI you use for executing automation.

After 10+ years of writing Java, I've only just written my first piece of GUI code, and that's because I'm writing an application to help my testing. Once you've followed Java For Testers, learning how to write a 'main' method and create an application will not take you long to learn. But I don't think you need it as one of the first things you learn.

The book now has:

  • 23 chapters
  • more exercises
  • more explanations
  • a Large Appendix with code for all the exercise answers
Because of all the easy to follow code examples in the body of the text, it is fairly fast to read, but you do need to spend the time working on the examples and exercises so that you gain practical experience of writing Java JUnit @Test code.


  •     Introduction
  •     Chapter One - Basics of Java Revealed
  •     Chapter Two - Install the Necessary Software
  •     Chapter Three - Writing Your First Java Code
  •     Chapter Four - Work with Other Classes
  •     Chapter Five - Working with Our Own Classes
  •     Chapter Six - Java Classes Revisited- Constructors, Fields, Getter & Setter Methods
  •     Chapter Seven - Basics of Java Revisited
  •     Chapter Eight - Selections and Decisions
  •     Chapter Nine - Arrays and For Loop Iteration
  •     Chapter Ten - Introducing Collections
  •     Chapter Eleven - Introducing Exceptions
  •     Chapter Twelve - Introducing Inheritance
  •     Chapter Thirteen - More About Exceptions
  •     Chapter Fourteen - JUnit Explored
  •     Chapter Fifteen - Strings Revisited
  •     Chapter Sixteen - Random Data
  •     Chapter Seventeen - Dates and Times
  •     Chapter Eighteen - Properties and Property Files
  •     Chapter Nineteen - Files
  •     Chapter Twenty - Math and BigDecimal
  •     Chapter Twenty One - Collections Revisited
  •     Chapter Twenty Two - Advancing Concepts
  •     Chapter Twenty Three - Next Steps
  •     Appendix - IntelliJ Hints and Tips
  •     Appendix - Exercise Answers


Full contents are available on the leanpub site :  leanpub.com/javaForTesters

You can read or download a sample of the book containing:


  •     Introduction
  •     Chapter One - Basics of Java Revealed
  •     Chapter Two - Install the Necessary Software
  •     Chapter Three - Writing Your First Java Code
  •     Chapter Four - Work with Other Classes
  •     Chapter Twenty Three - Next Steps
  •     Appendix - IntelliJ Hints and Tips


This should be good enough to get you started, for free.

The downloadable source code: [github.com/eviltester/javaForTestersCode]

  • structured into packages for each chapter
  • packages for 'examples' and 'exercises'
  • all code runs clean from 'mvn test'
  • you could add to a CI system if you wanted


All the code in the book is extracted from the downloadable source code, so there should be no code typos in the book.

All code is executed using the JUnit Test Runner, by annotating methods with @Test. So there is no need to build an executable or fiddle with manifest files.

This is the book I wanted to give people working for me when they started out learning to code for automation. And it covers the basics that I expect people to know in interviews when they say they can write automation code in Java.

Full details are over on the  leanpub.com/javaForTesters page.