当前位置: 首页>>代码示例>>Java>>正文


Java NbTestCase.fail方法代码示例

本文整理汇总了Java中org.netbeans.junit.NbTestCase.fail方法的典型用法代码示例。如果您正苦于以下问题:Java NbTestCase.fail方法的具体用法?Java NbTestCase.fail怎么用?Java NbTestCase.fail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.netbeans.junit.NbTestCase的用法示例。


在下文中一共展示了NbTestCase.fail方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: finish

import org.netbeans.junit.NbTestCase; //导入方法依赖的package包/类
public void finish() throws Exception {
    if (input == null) {
        if (!outputFile.createNewFile()) {
            NbTestCase.fail("Cannot create file " + outputFile);
        }
        FileWriter fw = new FileWriter(outputFile);
        try {
            fw.write(output.toString());
        } finally {
            fw.close();
        }
        NbTestCase.fail("Created tokens dump file " + outputFile + "\nPlease re-run the test.");

    } else {
        if (inputIndex < input.length()) {
            NbTestCase.fail("Some text left unread:" + input.substring(inputIndex));
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:TokenDumpCheck.java

示例2: getTestFile

import org.netbeans.junit.NbTestCase; //导入方法依赖的package包/类
protected FileObject getTestFile(String relFilePath) {
    File wholeInputFile = new File(getDataDir(), relFilePath);
    if (!wholeInputFile.exists()) {
        NbTestCase.fail("File " + wholeInputFile + " not found.");
    }
    FileObject fo = FileUtil.toFileObject(wholeInputFile);
    assertNotNull(fo);

    return fo;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:CslTestBase.java

示例3: getTestFile

import org.netbeans.junit.NbTestCase; //导入方法依赖的package包/类
private FileObject getTestFile(String relFilePath) {
    File wholeInputFile = new File(getDataDir(), relFilePath);
    if (!wholeInputFile.exists()) {
        NbTestCase.fail("File " + wholeInputFile + " not found.");
    }
    FileObject fo = FileUtil.toFileObject(wholeInputFile);
    assertNotNull(fo);

    return fo;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ValidationTransactionTest.java

示例4: assertFileContentsMatches

import org.netbeans.junit.NbTestCase; //导入方法依赖的package包/类
protected void assertFileContentsMatches(String relFilePath, String description, boolean includeTestName, String ext) throws Exception {
    File rubyFile = getDataFile(relFilePath);
    if (!rubyFile.exists()) {
        NbTestCase.fail("File " + rubyFile + " not found.");
    }

    File goldenFile = getDataFile(relFilePath + (includeTestName ? ("." + getName()) : "") + ext);
    if (!goldenFile.exists()) {
        if (!goldenFile.createNewFile()) {
            NbTestCase.fail("Cannot create file " + goldenFile);
        }
        FileWriter fw = new FileWriter(goldenFile);
        try {
            fw.write(description);
        }
        finally{
            fw.close();
        }
        NbTestCase.fail("Created generated golden file " + goldenFile + "\nPlease re-run the test.");
    }

    String expected = readFile(goldenFile);
    final String expectedTrimmed = expected.trim();
    final String actualTrimmed = description.trim();

    if (expectedTrimmed.equals(actualTrimmed)) {
        return; // Actual and expected content are equals --> Test passed
    } else {
        // We want to ignore different line separators (like \r\n against \n) because they
        // might be causing failing tests on a different operation systems like Windows :]
        final String expectedUnified = expectedTrimmed.replaceAll("\r", "");
        final String actualUnified = actualTrimmed.replaceAll("\r", "");

        if (expectedUnified.equals(actualUnified)) {
            return; // Only difference is in line separation --> Test passed
        }

        // There are some diffrerences between expected and actual content --> Test failed

        fail("Not matching goldenfile: " + FileUtil.getFileDisplayName(FileUtil.toFileObject(goldenFile)) + lineSeparator(2) + getContentDifferences(expectedUnified, actualUnified));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:43,代码来源:CslTestBase.java

示例5: compareLine

import org.netbeans.junit.NbTestCase; //导入方法依赖的package包/类
public void compareLine(CharSequence text, int tokenIndex) {
    if (input != null) {
        textLength = text.length();
        if (input.length() - inputIndex < textLength || !TokenUtilities.equals(text, this)) {
            StringBuilder msg = new StringBuilder(100);
            msg.append("\nDump file ");
            msg.append(outputFile);
            msg.append(":\n");
            msg.append(testName);
            msg.append(":\n");
            if (tokenIndex >= 0) {
                msg.append("Invalid token description in dump file (tokenIndex=");
                msg.append(tokenIndex);
                msg.append("):");
            } else {
                msg.append("Invalid text in dump file:");
            }
            msg.append("\n    ");
            msg.append(input.subSequence(inputIndex, findEOL(inputIndex)));
            msg.append("\nExpected:\n    ");
            msg.append(text);
            msg.append("\nPrevious context:\n");
            for (int i = 0; i < lineBoundsIndexes.length; i += 2) {
                int start = lineBoundsIndexes[i];
                if (start != -1) {
                    msg.append("    ");
                    msg.append(input.subSequence(start, lineBoundsIndexes[i + 1]));
                    msg.append('\n');
                }
            }
            NbTestCase.fail(msg.toString());
            
        }
        System.arraycopy(lineBoundsIndexes, 2, lineBoundsIndexes, 0, lineBoundsIndexes.length - 2);
        lineBoundsIndexes[lineBoundsIndexes.length - 2] = inputIndex;
        inputIndex += textLength;
        lineBoundsIndexes[lineBoundsIndexes.length - 1] = inputIndex;
        inputIndex = skipEOL(inputIndex);

    } else {
        output.append(text);
        String ls = (String) System.getProperty("line.separator"); // NOI18N
        output.append(ls);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:46,代码来源:TokenDumpCheck.java


注:本文中的org.netbeans.junit.NbTestCase.fail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。