org.netbeans.junit
Class NbTestCase

java.lang.Object
  |
  +--junit.framework.Assert
        |
        +--junit.framework.TestCase
              |
              +--org.netbeans.junit.NbTestCase
All Implemented Interfaces:
NbTest, junit.framework.Test

public abstract class NbTestCase
extends junit.framework.TestCase
implements NbTest

NetBeans extension to JUnit's TestCase


Constructor Summary
NbTestCase(java.lang.String name)
          Constructs a test case with the given name.
 
Method Summary
static void assertFile(java.io.File test, java.io.File pass)
          Asserts that two files are the same, it just compares two files and doesn't produce any additional output.
static void assertFile(java.io.File test, java.io.File pass, java.io.File diff)
          Asserts that two files are the same, it compares two files and stores possible differencies in the output file.
static void assertFile(java.io.File test, java.io.File pass, java.io.File diff, org.netbeans.junit.diff.Diff externalDiff)
          Asserts that two files are the same, it uses specific Diff implementation to compare two files and stores possible differencies in the output file.
static void assertFile(java.lang.String message, java.io.File test, java.io.File pass, java.io.File diff)
          Asserts that two files are the same, it compares two files and stores possible differencies in the output file, the message is displayed when assertion fails.
static void assertFile(java.lang.String message, java.io.File test, java.io.File pass, java.io.File diff, org.netbeans.junit.diff.Diff externalDiff)
          Asserts that two files are the same (their content is identical), when files differ AssertionFileFailedError exception is thrown.
static void assertFile(java.lang.String test, java.lang.String pass)
          Asserts that two files are the same, it just compares two files and doesn't produce any additional output.
static void assertFile(java.lang.String test, java.lang.String pass, java.lang.String diff)
          Asserts that two files are the same, it compares two files and stores possible differencies in the output file.
static void assertFile(java.lang.String test, java.lang.String pass, java.lang.String diff, org.netbeans.junit.diff.Diff externalDiff)
          Asserts that two files are the same, it uses specific Diff implementation to compare two files and stores possible differencies in the output file.
static void assertFile(java.lang.String message, java.lang.String test, java.lang.String pass, java.lang.String diff)
          Asserts that two files are the same, it compares two files and stores possible differencies in the output file, the message is displayed when assertion fails.
static void assertFile(java.lang.String message, java.lang.String test, java.lang.String pass, java.lang.String diff, org.netbeans.junit.diff.Diff externalDiff)
          Asserts that two files are the same (their content is identical), when files differ AssertionFileFailedError exception is thrown.
 boolean canRun()
          Checks if a test isn't filtered out by the active filter.
 void clearWorkDir()
          Deletes all files under test's working directory.
 java.lang.String getWorkDir()
          Returns unique working directory for a test (each test method have uniq1ue dir).
 void run(junit.framework.TestResult result)
          Runs the test case and collects the results in TestResult.
 void setFilter(Filter filter)
          Sets active filter.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, name, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assert, assert, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertNotNull, assertNotNull, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface junit.framework.Test
countTestCases
 

Constructor Detail

NbTestCase

public NbTestCase(java.lang.String name)
Constructs a test case with the given name.
Parameters:
name - name of the testcase
Method Detail

setFilter

public void setFilter(Filter filter)
Sets active filter.
Specified by:
setFilter in interface NbTest
Parameters:
filter - Filter to be set as active for current test, null will reset filtering.

canRun

public boolean canRun()
Checks if a test isn't filtered out by the active filter.
Specified by:
canRun in interface NbTest
Returns:
true if the test can run

run

public void run(junit.framework.TestResult result)
Runs the test case and collects the results in TestResult. overrides JUnit run, because filter check
Specified by:
run in interface junit.framework.Test
Overrides:
run in class junit.framework.TestCase

assertFile

public static void assertFile(java.lang.String message,
                              java.lang.String test,
                              java.lang.String pass,
                              java.lang.String diff,
                              org.netbeans.junit.diff.Diff externalDiff)
Asserts that two files are the same (their content is identical), when files differ AssertionFileFailedError exception is thrown. Depending on the Diff implementation additional output can be generated to the file/dir specified by the diff param.
Parameters:
message - the detail message for this assertion
test - first file to be compared, by the convention this should be the test-generated file
pass - second file to be comapred, it should be so called 'golden' file, which defines the correct content for the test-generated file.
diff - file, where differences will be stored, when null differences will not be stored. In case it points to directory the result file name is constructed from the pass argument and placed to that directory. Constructed file name consists from the name of pass file (without extension and path) appended by the '.diff'.
externalDiff - instance of class implementing the Diff interface, it has to be already initialized, when passed in this assertFile function.

assertFile

public static void assertFile(java.lang.String test,
                              java.lang.String pass,
                              java.lang.String diff,
                              org.netbeans.junit.diff.Diff externalDiff)
Asserts that two files are the same, it uses specific Diff implementation to compare two files and stores possible differencies in the output file.
Parameters:
test - first file to be compared, by the convention this should be the test-generated file
pass - second file to be comapred, it should be so called 'golden' file, which defines the correct content for the test-generated file.
diff - file, where differences will be stored, when null differences will not be stored. In case it points to directory the result file name is constructed from the pass argument and placed to that directory. Constructed file name consists from the name of pass file (without extension and path) appended by the '.diff'.
externalDiff - instance of class implementing the Diff interface, it has to be already initialized, when passed in this assertFile function.

assertFile

public static void assertFile(java.lang.String message,
                              java.lang.String test,
                              java.lang.String pass,
                              java.lang.String diff)
Asserts that two files are the same, it compares two files and stores possible differencies in the output file, the message is displayed when assertion fails.
Parameters:
message - the detail message for this assertion
test - first file to be compared, by the convention this should be the test-generated file
pass - second file to be comapred, it should be so called 'golden' file, which defines the correct content for the test-generated file.
diff - file, where differences will be stored, when null differences will not be stored. In case it points to directory the result file name is constructed from the pass argument and placed to that directory. Constructed file name consists from the name of pass file (without extension and path) appended by the '.diff'.

assertFile

public static void assertFile(java.lang.String test,
                              java.lang.String pass,
                              java.lang.String diff)
Asserts that two files are the same, it compares two files and stores possible differencies in the output file.
Parameters:
test - first file to be compared, by the convention this should be the test-generated file
pass - second file to be comapred, it should be so called 'golden' file, which defines the correct content for the test-generated file.
diff - file, where differences will be stored, when null differences will not be stored. In case it points to directory the result file name is constructed from the pass argument and placed to that directory. Constructed file name consists from the name of pass file (without extension and path) appended by the '.diff'.

assertFile

public static void assertFile(java.lang.String test,
                              java.lang.String pass)
Asserts that two files are the same, it just compares two files and doesn't produce any additional output.
Parameters:
test - first file to be compared, by the convention this should be the test-generated file
pass - second file to be comapred, it should be so called 'golden' file, which defines the correct content for the test-generated file.

assertFile

public static void assertFile(java.lang.String message,
                              java.io.File test,
                              java.io.File pass,
                              java.io.File diff,
                              org.netbeans.junit.diff.Diff externalDiff)
Asserts that two files are the same (their content is identical), when files differ AssertionFileFailedError exception is thrown. Depending on the Diff implementation additional output can be generated to the file/dir specified by the diff param.
Parameters:
message - the detail message for this assertion
test - first file to be compared, by the convention this should be the test-generated file
pass - second file to be comapred, it should be so called 'golden' file, which defines the correct content for the test-generated file.
diff - file, where differences will be stored, when null differences will not be stored. In case it points to directory the result file name is constructed from the pass argument and placed to that directory. Constructed file name consists from the name of pass file (without extension and path) appended by the '.diff'.
externalDiff - instance of class implementing the Diff interface, it has to be already initialized, when passed in this assertFile function.

assertFile

public static void assertFile(java.io.File test,
                              java.io.File pass,
                              java.io.File diff,
                              org.netbeans.junit.diff.Diff externalDiff)
Asserts that two files are the same, it uses specific Diff implementation to compare two files and stores possible differencies in the output file.
Parameters:
test - first file to be compared, by the convention this should be the test-generated file
pass - second file to be comapred, it should be so called 'golden' file, which defines the correct content for the test-generated file.
diff - file, where differences will be stored, when null differences will not be stored. In case it points to directory the result file name is constructed from the pass argument and placed to that directory. Constructed file name consists from the name of pass file (without extension and path) appended by the '.diff'.
externalDiff - instance of class implementing the Diff interface, it has to be already initialized, when passed in this assertFile function.

assertFile

public static void assertFile(java.lang.String message,
                              java.io.File test,
                              java.io.File pass,
                              java.io.File diff)
Asserts that two files are the same, it compares two files and stores possible differencies in the output file, the message is displayed when assertion fails.
Parameters:
message - the detail message for this assertion
test - first file to be compared, by the convention this should be the test-generated file
pass - second file to be comapred, it should be so called 'golden' file, which defines the correct content for the test-generated file.
diff - file, where differences will be stored, when null differences will not be stored. In case it points to directory the result file name is constructed from the pass argument and placed to that directory. Constructed file name consists from the name of pass file (without extension and path) appended by the '.diff'.

assertFile

public static void assertFile(java.io.File test,
                              java.io.File pass,
                              java.io.File diff)
Asserts that two files are the same, it compares two files and stores possible differencies in the output file.
Parameters:
test - first file to be compared, by the convention this should be the test-generated file
pass - second file to be comapred, it should be so called 'golden' file, which defines the correct content for the test-generated file.
diff - file, where differences will be stored, when null differences will not be stored. In case it points to directory the result file name is constructed from the pass argument and placed to that directory. Constructed file name consists from the name of pass file (without extension and path) appended by the '.diff'.

assertFile

public static void assertFile(java.io.File test,
                              java.io.File pass)
Asserts that two files are the same, it just compares two files and doesn't produce any additional output.
Parameters:
test - first file to be compared, by the convention this should be the test-generated file
pass - second file to be comapred, it should be so called 'golden' file, which defines the correct content for the test-generated file.

getWorkDir

public java.lang.String getWorkDir()
                            throws java.io.IOException
Returns unique working directory for a test (each test method have uniq1ue dir). If not available, method tries to create it.
Returns:
path to the working directory directory
Throws:
java.io.IOException - if the directory cannot be created

clearWorkDir

public void clearWorkDir()
                  throws java.io.IOException
Deletes all files under test's working directory.
Throws:
java.io.IOException - if any problem has occured during deleting files/directories