Search in sources :

Example 11 with JSLintResult

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

the class JUnitXmlFormatterTest method testNoProblems.

@Test
public void testNoProblems() throws Exception {
    String expected = "<testsuite failures=\"0\" time=\"0.000\" errors=\"0\" skipped=\"0\" " + "tests=\"1\" name=\"hello.js\">" + "<testcase time=\"0.000\" classname=\"com.googlecode.jslint4java\" name=\"hello.js\" />" + "</testsuite>";
    JSLintResult result = new JSLintResult.ResultBuilder("hello.js").duration(0).build();
    XMLAssert.assertXMLEqual(expected, form.format(result));
}
Also used : JSLintResult(com.googlecode.jslint4java.JSLintResult) Test(org.junit.Test)

Example 12 with JSLintResult

use of com.googlecode.jslint4java.JSLintResult 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));
}
Also used : Issue(com.googlecode.jslint4java.Issue) JSLintResult(com.googlecode.jslint4java.JSLintResult) Test(org.junit.Test)

Example 13 with JSLintResult

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

the class PlainFormatterTest method testExpectedOutputNoIssues.

@Test
public void testExpectedOutputNoIssues() {
    JSLintResult result = new JSLintResult.ResultBuilder("foo/bar.js").build();
    String out = rf.format(result);
    assertThat(out, is(""));
}
Also used : JSLintResult(com.googlecode.jslint4java.JSLintResult) Test(org.junit.Test)

Example 14 with JSLintResult

use of com.googlecode.jslint4java.JSLintResult 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()));
}
Also used : Issue(com.googlecode.jslint4java.Issue) JSLintResult(com.googlecode.jslint4java.JSLintResult) IssueBuilder(com.googlecode.jslint4java.Issue.IssueBuilder) Test(org.junit.Test)

Example 15 with JSLintResult

use of com.googlecode.jslint4java.JSLintResult 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()));
}
Also used : Issue(com.googlecode.jslint4java.Issue) JSLintResult(com.googlecode.jslint4java.JSLintResult) IssueBuilder(com.googlecode.jslint4java.Issue.IssueBuilder) Test(org.junit.Test)

Aggregations

JSLintResult (com.googlecode.jslint4java.JSLintResult)20 Test (org.junit.Test)17 Issue (com.googlecode.jslint4java.Issue)9 IssueBuilder (com.googlecode.jslint4java.Issue.IssueBuilder)3 BufferedReader (java.io.BufferedReader)2 JSLint (com.googlecode.jslint4java.JSLint)1 UnicodeBomInputStream (com.googlecode.jslint4java.UnicodeBomInputStream)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStreamReader (java.io.InputStreamReader)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1