Search in sources :

Example 6 with Issue

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

Example 7 with Issue

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

Example 8 with Issue

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

Example 9 with Issue

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

Example 10 with Issue

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=\"&quot;a&amp;b&apos;.js\">" + "<testcase time=\"0.000\" classname=\"com.googlecode.jslint4java\" " + "name=\"&quot;a&amp;b&apos;.js\">" + "<failure message=\"Found 1 problem\" type=\"java.lang.AssertionError\">" + "\"a&amp;b'.js:1:1:I&lt;&amp;&gt;Like&lt;angle&gt;&gt;\"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));
}
Also used : Issue(com.googlecode.jslint4java.Issue) JSLintResult(com.googlecode.jslint4java.JSLintResult) Test(org.junit.Test)

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