use of com.googlecode.jslint4java.Issue in project jslint4java by happygiraffe.
the class JSLintXmlFormatterTest method testOneIssue.
@Test
public void testOneIssue() throws Exception {
String name = "bad.js";
Issue issue = new Issue.IssueBuilder(name, 1, 1, "too many goats teleported").build();
JSLintResult result = new JSLintResult.ResultBuilder(name).addIssue(issue).build();
String expected = "<file name='bad.js'>" + "<issue line='1' char='1' reason='too many goats teleported' evidence='' />" + "</file>";
String actual = form.format(result);
XMLAssert.assertXMLEqual(expected, actual);
XMLAssert.assertXMLValid(getValidatorFor(actual));
}
use of com.googlecode.jslint4java.Issue in project jslint4java by happygiraffe.
the class JUnitXmlFormatterTest method testTwoProblems.
// Just to get the coverage scores up…
@Test
public void testTwoProblems() throws Exception {
String expected = "<testsuite failures=\"1\" time=\"0.000\" errors=\"1\" skipped=\"0\" " + "tests=\"1\" name=\"hello.js\">" + "<testcase time=\"0.000\" classname=\"com.googlecode.jslint4java\" name=\"hello.js\">" + "<failure message=\"Found 2 problems\" type=\"java.lang.AssertionError\">" + "hello.js:1:1:too many aardvarks\n" + "hello.js:1:2:too few aardvarks\n" + "</failure>" + "</testcase>" + "</testsuite>";
String name = "hello.js";
Issue issue1 = new Issue.IssueBuilder(name, 1, 1, "too many aardvarks").build();
Issue issue2 = new Issue.IssueBuilder(name, 1, 2, "too few aardvarks").build();
JSLintResult result = new JSLintResult.ResultBuilder(name).duration(0).addIssue(issue1).addIssue(issue2).build();
XMLAssert.assertXMLEqual(expected, form.format(result));
}
use of com.googlecode.jslint4java.Issue in project jslint4java by happygiraffe.
the class PlainFormatterTest method testNoEvidence.
/**
* When there's no evidence, we shouldn't print a blank line or a caret.
*/
@Test
public void testNoEvidence() throws Exception {
String nl = System.getProperty("line.separator");
String name = "foo/bar.js";
Issue issue = new IssueBuilder(name, 1, 1, "fatality").build();
JSLintResult result = new JSLintResult.ResultBuilder(name).addIssue(issue).build();
StringBuilder sb = new StringBuilder(name);
sb.append(":1:1: fatality");
sb.append(nl);
assertThat(rf.format(result), is(sb.toString()));
}
use of com.googlecode.jslint4java.Issue in project jslint4java by happygiraffe.
the class PlainFormatterTest method testExpectedOutputOneIssue.
@Test
public void testExpectedOutputOneIssue() {
String nl = System.getProperty("line.separator");
String name = "foo/bar.js";
Issue issue = new IssueBuilder(name, 1, 2, "no clucking").evidence("cluck()").build();
JSLintResult result = new JSLintResult.ResultBuilder(name).addIssue(issue).build();
StringBuilder sb = new StringBuilder(name);
sb.append(":1:2: no clucking").append(nl);
sb.append("cluck()").append(nl);
sb.append(" ^").append(nl);
assertThat(rf.format(result), is(sb.toString()));
}
use of com.googlecode.jslint4java.Issue in project jslint4java by happygiraffe.
the class JUnitXmlFormatterTest method testEscaping.
@Test
public void testEscaping() throws Exception {
String expected = "<testsuite failures=\"1\" time=\"0.000\" errors=\"1\" skipped=\"0\" " + "tests=\"1\" name=\""a&b'.js\">" + "<testcase time=\"0.000\" classname=\"com.googlecode.jslint4java\" " + "name=\""a&b'.js\">" + "<failure message=\"Found 1 problem\" type=\"java.lang.AssertionError\">" + "\"a&b'.js:1:1:I<&>Like<angle>>\"brackets'\n" + "</failure>" + "</testcase>" + "</testsuite>";
String name = "\"a&b\'.js";
Issue issue = new Issue.IssueBuilder(name, 1, 1, "I<&>Like<angle>>\"brackets\'").build();
JSLintResult result = new JSLintResult.ResultBuilder(name).duration(0).addIssue(issue).build();
XMLAssert.assertXMLEqual(expected, form.format(result));
}
Aggregations