Skip to content

Instantly share code, notes, and snippets.

@ankschoubey
Last active March 19, 2022 08:39
Show Gist options
  • Save ankschoubey/ea3cb41308c19f56c69eb40d7e05cec1 to your computer and use it in GitHub Desktop.
Save ankschoubey/ea3cb41308c19f56c69eb40d7e05cec1 to your computer and use it in GitHub Desktop.
format for writing clean junit tests
class {NameOfClass}Tests{
@Nested
@DisplayName("{methodName} method")
class {MethodName}Tests{
@Nested
@DisplayName("WHEN {condition description}")
class {ConditionDescription}Tests{
@Nested
@DisplayName("SHOULD {assertion description}")
class {AssertionDescription}Tests{
// GIVEN
{code for setting conditions describe in WHEN block}
// WHEN
{code for running actions}
// THEN
{code for assertions}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment