Search in sources :

Example 11 with Issue

use of com.googlecode.jslint4java.Issue in project jslint4java by happygiraffe.

the class JUnitXmlFormatterTest method testOneProblem.

@Test
public void testOneProblem() 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 1 problem\" type=\"java.lang.AssertionError\">" + "hello.js:1:1:too many aardvarks\n" + "</failure>" + "</testcase>" + "</testsuite>";
    String name = "hello.js";
    Issue issue = new Issue.IssueBuilder(name, 1, 1, "too many aardvarks").build();
    JSLintResult result = new JSLintResult.ResultBuilder(name).duration(0).addIssue(issue).build();
    XMLAssert.assertXMLEqual(expected, form.format(result));
}
Also used : Issue(com.googlecode.jslint4java.Issue) JSLintResult(com.googlecode.jslint4java.JSLintResult) Test(org.junit.Test)

Example 12 with Issue

use of com.googlecode.jslint4java.Issue in project jslint4java by happygiraffe.

the class PlainFormatterTest method shouldCopeWithCharacterZero.

/** We don't expect this to happen, but we shouldn't blow up either. @see issue 85 */
@Test
public void shouldCopeWithCharacterZero() throws Exception {
    String nl = System.getProperty("line.separator");
    String name = "foo/bar.js";
    Issue issue = new IssueBuilder(name, 0, 0, "oops").evidence("BANG").build();
    JSLintResult result = new JSLintResult.ResultBuilder(name).addIssue(issue).build();
    StringBuilder sb = new StringBuilder(name);
    sb.append(":0:0: oops").append(nl);
    sb.append("BANG").append(nl);
    sb.append("^").append(nl);
    assertThat(rf.format(result), is(sb.toString()));
}
Also used : Issue(com.googlecode.jslint4java.Issue) JSLintResult(com.googlecode.jslint4java.JSLintResult) IssueBuilder(com.googlecode.jslint4java.Issue.IssueBuilder) Test(org.junit.Test)

Example 13 with Issue

use of com.googlecode.jslint4java.Issue in project jslint4java by happygiraffe.

the class MultiReportWriterTest method makeResult.

private JSLintResult makeResult() {
    String filename = "foo.js";
    Issue issue = new Issue.IssueBuilder(filename, 1, 1, "bad code").build();
    return new JSLintResult.ResultBuilder(filename).addIssue(issue).build();
}
Also used : Issue(com.googlecode.jslint4java.Issue)

Example 14 with Issue

use of com.googlecode.jslint4java.Issue in project jslint4java by happygiraffe.

the class PlainResultFormatterTest method testExpectedOutputOneIssue.

@Test
public void testExpectedOutputOneIssue() {
    File file = new File("foo/bar.js");
    Issue issue = new IssueBuilder(file.toString(), 1, 1, "no clucking").evidence("cluck()").build();
    issues.add(issue);
    runFormatter(file);
    // Build up the expected output in a cross-platform manner.
    String nl = System.getProperty("line.separator");
    StringBuilder sb = new StringBuilder(file.toString());
    sb.append(":1:1: no clucking");
    sb.append(nl);
    sb.append("cluck()");
    sb.append(nl);
    sb.append("^");
    sb.append(nl);
    // NB: We use platform encoding here, as that's what we expect the
    // formatter to produce.
    assertThat(out.toString(), is(sb.toString()));
}
Also used : Issue(com.googlecode.jslint4java.Issue) File(java.io.File) IssueBuilder(com.googlecode.jslint4java.Issue.IssueBuilder) Test(org.junit.Test)

Example 15 with Issue

use of com.googlecode.jslint4java.Issue in project jslint4java by happygiraffe.

the class PlainResultFormatterTest method runFormatter.

/**
     * Run the formatter over the current set of issues. The File as input is
     * just a convenient way of passing a name & path together.
     */
private void runFormatter(File file) {
    rf.begin();
    ResultBuilder builder = new JSLintResult.ResultBuilder(file.getName());
    for (Issue issue : issues) {
        builder.addIssue(issue);
    }
    rf.output(builder.build());
    rf.end();
}
Also used : ResultBuilder(com.googlecode.jslint4java.JSLintResult.ResultBuilder) Issue(com.googlecode.jslint4java.Issue)

Aggregations

Issue (com.googlecode.jslint4java.Issue)16 Test (org.junit.Test)11 JSLintResult (com.googlecode.jslint4java.JSLintResult)9 IssueBuilder (com.googlecode.jslint4java.Issue.IssueBuilder)5 File (java.io.File)2 ResultBuilder (com.googlecode.jslint4java.JSLintResult.ResultBuilder)1