Two Java Beginner Coding Tips

2 minute read - Java For Testers

TLDR; Coding Tips for beginners.Write your code as temporary comments, remove syntax errors as soon as you see them.

Here are a few tips I’ve been verbally passing on when teaching people on my Java For Testers face to face training.


JUnit5 Assertion Migration Strategy

5 minute read - Java For Testers

TLDR; Rather than migration your assertions line by line, create an abstraction class to represent the new implementation and then perform inline refactoring.

I’m experimenting with migrating my projects to JUnit 5.

Many of the “how to migrate to JUnit 5” blog posts show differences, but not a lot of strategies. I used a Branch By Abstraction strategy to migrate JUnit 4 Assertions. This allowed me to experiment with using JUnit5 assertions or AssertJ assertions.


MVP and API Thinking When Coding

10 minute read - Java For Testers

TLDR; Apply MVP principles when coding. Code to the API first. The API is internal before it is external. Unit tests with classes. In code testing with classes in combination. In code API testing. External HTTP API Testing. And then if necessary -In memory and process HTTP API testing. GUI.

A long time ago, in a town which I no longer live in, I wrote a tool called Compendium-TA

Commercially that was a disaster: it was self funded, it took a long time to write and I made some poor technology decisions.

I learned MVP and API First Thinking the hard way. I’ll try and explain within.


Migrating from JAXB XML processing to XStream

6 minute read - REST API Java For Testers

TLDR: refactored to isolate XML processing, configured XStream in code, removed all annotations, added XML header, wrote less code

I have a small REST API application which uses Spark and GSON and JAXB. I haven’t released this to Github yet but I did release some of the example externally executed []integration verification code](https://github.com/eviltester/automating-rest-api) for it.

When trying to package this for Java 1.9 I encountered the, now standard, missing JAXB, libraries. So I thought I’d investigate another XML library.


Simple ways to add and work with a `.jar` file in your local maven setup

5 minute read - Maven Java For Testers

TL;DR Hack - add as a library in IntelliJ project. Tactic - add as system scope in maven. Tactic/Strategic - install locally to .m2. Strategic - use a repository management tool, publish to maven central

Sometimes you want to work with a jar file that isn’t hosted in maven central.

It might be a 3rd party jar, it might be one that you have written.

Regardless.

You have a lot of options for this. The approaches that I have used:

  • add .jar files as an IntelliJ project dependency
  • install it locally to your .m2 repository
  • add it to your project as a system scoped file
  • use a repository management tool: like Nexus or Archiva
  • publish the dependency to maven central