문제

I use Eclipse and Maven and have made a single JUnit test, just to test if it works. The first time I ran the test everything went as expected, but since then, every time I run it, I get the same result, even though I'm changing the actual test-file's content.

I tried just emptying the file, then it said that there are no JUnit test files. But as long as I just have @Test in front of a method in that file, I always get the same results. Anyone know why that could be?

I tried restarting eclipse.

EDIT: Just realized that I'm not getting the test results since there is an exception before it gets tested. So, the problem is that I'm always getting the exception even though I changed the file.

Testclass:

public class zipTester {
/**
 * The class to be tested on.
 */
private Generator generator;

/**
 * Sets up the generator.
 */
@Before
public void setUp() {
    generator = new Generator(null, 0);
}
/**
 * Creates a zip file and tests whether it exists.
 */
@Test
public void testCreateZip() {
    File file = new File("/Users/nicola/Documents/trunk);
    generator.createZip(file, new Vector<File>());
}
}

Changed TestClass:

public class zipTester {
    @Test 
    public void heyo() {

    }
}

Always getting the following Exception:

java.io.FileNotFoundException: /Users/nicola/Documents/trunk (No such file or directory) ...

도움이 되었습니까?

해결책

1 May be you should clean your project
2 and then recheck project-BuildAutomatically
if still have something wrong,
you can right-click your project "java build path" and open the first tab Source
set default output folder content "test/target/classes"
good luck :)

i think your code was not compiled by eclipse

다른 팁

Seems that happen when there is no file in the relevant location.Because you are passing the file to Generator and try to access that file.Then this exception happen as there are no file to access with generator.

You can follow the below steps to avoid this scenario.

First check is that file exist in that location as below,

File file = new File("/Users/nicola/Documents/trunk"); assertTrue(file.exists());

Then check with your Generator.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top