Tag Archives: junit

Eclipse Java

Eclipse/JUnit: CreateProcess error=206, The filename or extension is too long

If you encounter problems with running junit test in Eclipse and you get following exception:

Exception occurred executing command line.
Cannot run program "C:\Program Files\Java\jdk1.7.0\bin\javaw.exe" (in directory "C:\......"):
CreateProcess error=206, The filename or extension is too long

please download patch for Eclipse.

For Eclipse Juno and newer:
https://bugs.eclipse.org/bugs/attachment.cgi?id=216593
For older Eclipse:
https://bugs.eclipse.org/bugs/attachment.cgi?id=219900

After download back up existing eclipse/plugins/org.eclipse.jdt.launching_3.*.jar
Copy and paste classes in the patch to org.eclipse.jdt.launching JAR (replace existing files).
Restart Eclipse.

For me it worked.

In bug report Bug 327193 it is considered fixed, but it happen to me recently with Eclipse Kepler 4.3.2.

Java

How NOT to write tests and improve coverage

Recently I’ve found nice way of writing tests and improving test coverage.

Check this example:

public enum Fields {
	SEARCH_TYPE,
	SEARCH_CITIES,
	SEARCH_DATES,
    ...
    POINT_OF_SALE;

	public Fields[] getValues() {
		return Fields.values();
	}
}

As you can see this is quite common enum. So how to improve test coverage?

Lets write some test! You can ask how to write tests for enums. Here it goes:

public class FieldsTest extends TestCase
{
    public void test()
    {
        for (Fields type : Fields.values())
        {
            assertEquals(type, type);
        }
    }
}

You can do this if you want to sell your source code to some company and show statistics about test coverage. Something like pig in a poke.

PS. Of course it’s a joke. Never ever do this!

Android

Running junit tests with Android

If you follow best practises you will probably face the same problem as many other developers. You junit test cases will not run. I was getting VM error like this: read more »