Den Dribbles

Java Anagrams

October 22, 2018

Gradle setup

For our build.gradle file:

apply plugin: "java"
apply plugin: "eclipse"
apply plugin: "idea"

repositories {

dependencies {
    testCompile "junit:junit:4.12"
test {
    testLogging {
        exceptionFormat = 'full'
        events = ["passed", "failed", "skipped"]

Setting up the Tests

Create file src/test/java/

import org.junit.Ignore;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class AnagramsTest {
    public void testAnEmptyString() {
        assertEquals("", new Anagrams().hello(""));

    @Ignore("Remove to run test")
    public void testAWord() {
        assertEquals("False", new Anagrams().hello(""));


In src/main/java/


Running tests

Run gradle test to compile and test our Anagrams class.

Related Articles

A personal blog on all things of interest. Written by Dennis O'Keeffe, Follow me on Twitter