Skip to content

Instantly share code, notes, and snippets.

@devilelephant
Created July 3, 2014 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devilelephant/92a90d31e92219feaba4 to your computer and use it in GitHub Desktop.
Save devilelephant/92a90d31e92219feaba4 to your computer and use it in GitHub Desktop.
Format log output that is compatible with Intellij Idea <Click to see difference> diff viewer
// The example is in Groovy but this probably works for any kind of logging for an app/test running in IDEA
// The important part is the template: "ComparisonFailure\nexpected:<{?}> but was:<{?}>"
// This works for multi-line values for each '?', which is why being able to use in-ide diff is so nice
def expected = ...
def actual = ...
// do your custom comparison, then if fails throw:
String msg = "ComparisonFailure\nexpected:<{${expected}}> but was:<{${actual}}>"
throw new AssertionError(msg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment