This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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}}>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cmd = ['sh', '-c', 'ls -l | sort'] | |
def p = cmd.execute() | |
println p.text | |
// Java would be something like | |
// String[] cmd = { "sh", "-c", "ls -l | sort" }; | |
// Process p = Runtime.getRuntime().exec(cmd); | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def out = new StringWriter() | |
def xml = new groovy.xml.MarkupBuilder(out) | |
// MarkupBuilder gives us an instance of MarkupBuilderHelper named 'mkp' | |
// MarkupBuilderHelper has several helpful methods | |
xml.mkp.xmlDeclaration(version: "1.0", encoding: "utf-8") | |
xml.example { | |
a { | |
b { | |
mkp.comment('a comment') |
NewerOlder