|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--junit.framework.Assert | +--junit.framework.TestCase | +--org.netbeans.junit.NbTestCase
NetBeans extension to JUnit's TestCase. This extension adds mostly possibility to compare files (assertFile).
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 including subdirectories in test's working directory. |
void |
compareReferenceFiles()
Compares default golden file and default reference log. |
void |
compareReferenceFiles(java.lang.String testFilename,
java.lang.String goldenFilename,
java.lang.String diffFilename)
Compares golden file and reference log. |
static java.lang.String |
convertNBFSURL(java.net.URL url)
Converts NetBeans filesystem URL to absolute path. |
java.io.File |
getGoldenFile()
Get the default testmethod specific golden file from data/goldenfiles/${classname}/${testmethodname}.pass |
java.io.File |
getGoldenFile(java.lang.String filename)
Get the testmethod specific golden file from data/goldenfiles/${classname} resource directory. |
java.io.PrintStream |
getLog()
Return default log named as ${testmethod}.log. |
java.io.PrintStream |
getLog(java.lang.String logName)
Returns named log stream. |
java.io.PrintStream |
getRef()
Get PrintStream to log inteded for reference files comparision. |
java.io.File |
getWorkDir()
Returns unique working directory for a test (each test method have uniq1ue dir). |
java.lang.String |
getWorkDirPath()
Returns path to test method working directory as a String. |
void |
log(java.lang.String message)
Simple and easy to use method for printing a message to a default log |
void |
log(java.lang.String log,
java.lang.String message)
Easy to use method for logging a message to a named log |
void |
ref(java.lang.String message)
Easy to use logging method for printing a message to a reference log. |
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 |
public NbTestCase(java.lang.String name)
name
- name of the testcaseMethod Detail |
public void setFilter(Filter filter)
setFilter
in interface NbTest
filter
- Filter to be set as active for current test, null will reset filtering.public boolean canRun()
canRun
in interface NbTest
public void run(junit.framework.TestResult result)
run
in interface junit.framework.Test
run
in class junit.framework.TestCase
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)
AssertionFileFailedError
exception is thrown.
Depending on the Diff implementation additional output can be generated to the file/dir specified by the
diff param.
message
- the detail message for this assertiontest
- first file to be compared, by the convention this should be the test-generated filepass
- 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.public static void assertFile(java.lang.String test, java.lang.String pass, java.lang.String diff, org.netbeans.junit.diff.Diff externalDiff)
Diff
implementation to
compare two files and stores possible differencies in the output file.
test
- first file to be compared, by the convention this should be the test-generated filepass
- 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.public static void assertFile(java.lang.String message, java.lang.String test, java.lang.String pass, java.lang.String diff)
message
- the detail message for this assertiontest
- first file to be compared, by the convention this should be the test-generated filepass
- 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'.public static void assertFile(java.lang.String test, java.lang.String pass, java.lang.String diff)
test
- first file to be compared, by the convention this should be the test-generated filepass
- 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'.public static void assertFile(java.lang.String test, java.lang.String pass)
test
- first file to be compared, by the convention this should be the test-generated filepass
- second file to be comapred, it should be so called 'golden' file, which defines the
correct content for the test-generated file.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)
AssertionFileFailedError
exception is thrown.
Depending on the Diff implementation additional output can be generated to the file/dir specified by the
diff param.
message
- the detail message for this assertiontest
- first file to be compared, by the convention this should be the test-generated filepass
- 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.public static void assertFile(java.io.File test, java.io.File pass, java.io.File diff, org.netbeans.junit.diff.Diff externalDiff)
Diff
implementation to
compare two files and stores possible differencies in the output file.
test
- first file to be compared, by the convention this should be the test-generated filepass
- 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.public static void assertFile(java.lang.String message, java.io.File test, java.io.File pass, java.io.File diff)
message
- the detail message for this assertiontest
- first file to be compared, by the convention this should be the test-generated filepass
- 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'.public static void assertFile(java.io.File test, java.io.File pass, java.io.File diff)
test
- first file to be compared, by the convention this should be the test-generated filepass
- 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'.public static void assertFile(java.io.File test, java.io.File pass)
test
- first file to be compared, by the convention this should be the test-generated filepass
- second file to be comapred, it should be so called 'golden' file, which defines the
correct content for the test-generated file.public java.lang.String getWorkDirPath() throws java.io.IOException
java.io.IOException
- if nbjunit.workdir property has not been setpublic java.io.File getWorkDir() throws java.io.IOException
java.io.IOException
- if the directory cannot be createdpublic void clearWorkDir() throws java.io.IOException
java.io.IOException
- if any problem has occured during deleting files/directoriespublic java.io.PrintStream getLog(java.lang.String logName)
logName
- name of the log - file in the working directory
public java.io.PrintStream getLog()
public void log(java.lang.String message)
message
- meesage to logpublic void log(java.lang.String log, java.lang.String message)
log
- which log to usemessage
- message to logpublic java.io.PrintStream getRef()
public void ref(java.lang.String message)
message
- message to logpublic java.io.File getGoldenFile(java.lang.String filename)
filename
- filename to get from golden files resource directory
public java.io.File getGoldenFile()
public void compareReferenceFiles(java.lang.String testFilename, java.lang.String goldenFilename, java.lang.String diffFilename)
testFilename
- reference log file namegoldenFilename
- golden file namediffFilename
- diff file name (optional, if null, then no diff is created)public void compareReferenceFiles()
public static java.lang.String convertNBFSURL(java.net.URL url)
url
- URL to convert
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |