UnitTests in SDK Knime

I have downloaded eclipse_knime_3.1.0 x64.

I have problem with running unit tests for my nodes since one of my nodes use:

import org.knime.core.util.FileUtil;

I run unit test in eclipse by click on the class: Run As->JUnitTest

I also tried using NGUnitTestRunner, I have created a class that implement AbstractTestcaseCollector, output was always empty.

How should I test my unit tests for code, which using a class from Knime core package?

 

Since your code is in a plug-in (I assume) You must run the test as "JUnit plug-in test".

Thanks! This has helped.

I have another question to JUnit plugin test:

this.getClass.getResource("resource.txt").getFile() in JUnit plug-in test returns other path than Junit test, why? How can I achive the same result?

For JUnit plug-in test result is like "E:\...\org\...\resource.txt"

For JUnit test results is like "\org\...\resource.txt"

You are assuming that the URL to the resource is a file URL. However, this is not always the case, especially not when run inside Eclipse. It can also be a path inside a Jar file. If you really need the physical path you need to to something like FileLocator.toFileURL.