Menu

#64 All junit tests are not being run

closed
nobody
None
1
2015-02-11
2014-12-10
mercury
No

Some of the unit tests are not run via maven test. Tests like DOMAssignDirect don't have a Test at the end, and hence they are not run.

There are two solutions to this:
1. Either rename these classes to have a Test suffix.
2. Or ensure the tests are run by configuring maven plugins correctly as described here: https://maven.apache.org/surefire/maven-surefire-plugin/examples/junit.html

I couldn't get (2) to work, but I am not a maven expert. (1) works fine. If you are okay I can make a PR with (1)

Discussion

  • mercury

    mercury - 2014-12-10

    I encountered this while making a test-case for issue #63.

    Here's my test-case:

    // Test for issue #63
    @Test
    public void testDimensionlessValues() throws SAXException, IOException, CSSException   {
    
        final String css = "#d1 {right:0;} #d2 { right:10; }";
        final String html = "<html><body><div id='d1'>text</div><div id='d2'>text</div></body></html> ";
    
        final InputStream is = new ByteArrayInputStream(html.getBytes());
        final DOMSource ds = new DOMSource(is);
        final Document doc = ds.parse();
        final ElementMap elements = new ElementMap(doc);
        final StyleSheet style = CSSFactory.parseString(css, null);
    
        final DirectAnalyzer da = new DirectAnalyzer(style);
        final NodeData nodeData1 = da.getElementStyle(elements.getElementById("d1"), null, "screen");
        assertThat("right", nodeData1.getValue(TermLength.class, "right"), is(tf.createLength(0f, Unit.px)));
    
        final NodeData nodeData2 = da.getElementStyle(elements.getElementById("d2"), null, "screen");
        assertThat("right", nodeData2.getValue(TermLength.class, "right"), is(tf.createLength(10f, Unit.px)));
    
    }
    

    The second sub-test fails.

     
  • mercury

    mercury - 2014-12-11

    After 8 hours of work, found the solution: maven won't run tests unless the classes have a Test prefix or suffix.

    Source: http://stackoverflow.com/questions/6178583/maven-does-not-find-junit-tests-to-run/

    I will submit a PR with files renamed.

     
  • Radek Burget

    Radek Burget - 2014-12-14

    Wow, well done. I was running the tests locally in Eclipse so I didn't notice this.

     
  • Radek Burget

    Radek Burget - 2014-12-17

    Ok, seems to be fixed by your PR #8 & #9.

     
  • Radek Burget

    Radek Burget - 2014-12-17
    • status: open --> accepted
     
  • Radek Burget

    Radek Burget - 2015-02-11
    • status: accepted --> closed
     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.