开发者

Detail Hudson test reports

Is there any way to force Hudson to give me more detailed 开发者_Go百科test results - e.g. I'm comparing two strings and I want to know where they differ. Is there any way to do this? Thank you for help.


You should not hope Hudson give the detail information, it just shows the testing messages generated by junit.

You could show the expected string and actual string when failing asserting equals between those two strings.

For example,

protected void compareFiles(File newFile, String referenceLocation, boolean lineNumberMatters) {
    BufferedReader reader = null;
    BufferedReader referenceReader = null;
    List<String> expectedLines = new ArrayList<String>();
    try {
        referenceReader = new BufferedReader(new InputStreamReader(FileLocator.openStream(Activator.getDefault().getBundle(), new Path("data/regression/" + referenceLocation), false)));  //$NON-NLS-1$
        expectedLines = getLinesFromReader(referenceReader);
    } catch (Exception e) {
        assertFalse("Exception occured during reading reference data: " + e, true); //$NON-NLS-1$
    }
    List<String>foundLines = new ArrayList<String>();
    try {
        reader = new BufferedReader(new FileReader(newFile));
        foundLines = getLinesFromReader(reader);
    } catch (Exception e) {
        assertFalse("Exception occured during reading file: " + e, true); //$NON-NLS-1$
    }
    boolean throwException = expectedLines.size() != foundLines.size();
    if (throwException) {
        StringBuffer buffer = new StringBuffer("\n" + newFile.toString()); //$NON-NLS-1$
        for (String line: foundLines)
            buffer.append(line + "\n"); //$NON-NLS-1$
        assertEquals("The number of lines in the reference(" + referenceLocation + ") and new output(" + newFile.getAbsolutePath()+ ") did not match!" + buffer, expectedLines.size(), foundLines.size()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }
    if (!lineNumberMatters) {
        Collections.sort(expectedLines);
        Collections.sort(foundLines);
    }
    /** Either the line matches character by character or it matches regex-wise, in that order */
    for (int i=0;i<expectedLines.size(); i++)
        assertTrue("Found errors in file (" + newFile + ")! " + foundLines.get(i) + " vs. " + expectedLines.get(i), foundLines.get(i).equals(expectedLines.get(i)) || foundLines.get(i).matches(expectedLines.get(i))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}


Hudson supports JUnit directly. On your job configuration page, near the end, should be an option to "Publish JUnit test results report".

I'm not too familiar with JUnit itself, but I guess it produces (or has the ability to produce) and put results in an xml file. You just need to put the path of to the xml file (relative to the workspace) in the text box.

Once you do that, and create a build, you'll have a detailed report on your project page. You should then be able to click your way through the results for each test.

Detail Hudson test reports

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜