Back to home

Gradle setupSetting up the TestsAnagramsRunning tests
Java Anagrams main image

Java Anagrams

Gradle setup

For our build.gradle file:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 apply plugin: "java" apply plugin: "eclipse" apply plugin: "idea" repositories { mavenCentral() } dependencies { testCompile "junit:junit:4.12" } test { testLogging { exceptionFormat = 'full' events = ["passed", "failed", "skipped"] } }

Setting up the Tests

Create file src/test/java/AnagramsTest.java:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 import org.junit.Ignore; import org.junit.Test; import static org.junit.Assert.assertEquals; public class AnagramsTest { @Test public void testAnEmptyString() { assertEquals("", new Anagrams().hello("")); } @Ignore("Remove to run test") @Test public void testAWord() { assertEquals("False", new Anagrams().hello("")); } }

Anagrams

In src/main/java/Anagrams.java:

1 // TO FINISH

Running tests

Run gradle test to compile and test our Anagrams class.

Dennis O'Keeffe

@dennisokeeffe92
  • Melbourne, Australia

Hi, I am a professional Software Engineer. Formerly of Culture Amp, UsabilityHub, Present Company and NightGuru.
I am currently working on workingoutloud.dev, Den Dribbles and LandPad .

Related articles


1,200+ PEOPLE ALREADY JOINED ❤️️

Get fresh posts + news direct to your inbox.

No spam. We only send you relevant content.