Skip to content

Instantly share code, notes, and snippets.

@joshden
Last active November 17, 2018 06:56
Show Gist options
  • Save joshden/7218f491a5a03e20065dda023d9915a8 to your computer and use it in GitHub Desktop.
Save joshden/7218f491a5a03e20065dda023d9915a8 to your computer and use it in GitHub Desktop.
Simple example of unit test class for JUnit 4
package com.example;
import org.junit.Test;
import static org.junit.Assert.*;
public class PersonTest {
@Test
public void testGetDisplayName() {
Person person = new Person("Josh", "Hayden");
String displayName = person.getDisplayName();
assertEquals("Hayden, Josh", displayName);
}
}
@ahmadhosny
Copy link

The only difference between this code and the jUnit5 code in your Toptal blog post is the public modifier. Correct?

@darshitpp
Copy link

The only difference between this code and the jUnit5 code in your Toptal blog post is the public modifier. Correct?

Yeah, looks like it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment