Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

junit5 console launcher doesn't run Junit4 tests #76

Closed
k-bhavitha opened this issue Jul 10, 2018 · 10 comments
Closed

junit5 console launcher doesn't run Junit4 tests #76

k-bhavitha opened this issue Jul 10, 2018 · 10 comments

Comments

@k-bhavitha
Copy link

I've forked this https://github.com/junit-team/junit5-samples/tree/master/junit5-jupiter-starter-ant

I then added a sample Junit4 test under test junit5-jupiter-starter-ant/src/test/java/com/example/project/

Launcher o/p:
Ran the build.sh expecting the vintage engine to show the run o/p.
image

image
My new class is not being picked by vintage

@sormuras
Copy link
Member

sormuras commented Jul 10, 2018

Thanks for creating this new issue and providing more details.

One more question: what is the file/class name of you JUnit 4 test?

@k-bhavitha
Copy link
Author

CalculatorJunit4Tests.java

@sormuras
Copy link
Member

sormuras commented Jul 10, 2018

Okay, the s is at the end. If you want to include classes ending with Test you need to include them like:

        <junitlauncher haltOnFailure="true" printSummary="true">
            <classpath refid="test.classpath"/>
            <testclasses outputdir="build/test-report">
                <fileset dir="build/test">
                    <include name="**/*Tests.class"/>
                    <include name="**/*Test.class"/>
                </fileset>
...

Now to the content of CalculatorJunit4Tests.java. Can you please post it here, too?

@sormuras
Copy link
Member

Looks like <junitlauncher> is started twice. Could be an issue with the task implementation.

@k-bhavitha
Copy link
Author

k-bhavitha commented Jul 10, 2018

package com.example.project;

import org.junit.Test;
class CalculatortJunit4Tests{
@Test(expected = AssertionError.class)
public void assertErrorOldStyle() 	{throw new AssertionError(); 	}
}

@sormuras
Copy link
Member

sormuras commented Jul 10, 2018

JUnit 3 and 4 classes need to be public.
@test is lower-case?! Added formatting your post. See https://guides.github.com/features/mastering-markdown/ for formatting features.

@k-bhavitha
Copy link
Author

k-bhavitha commented Jul 10, 2018

Thanks! that worked..but a quick question
Are we not supposed to add the vintage jars/jupiter for junitlauncher task ?
How is that working without any

@sormuras
Copy link
Member

sormuras commented Jul 10, 2018

Are we not supposed to add the vintage jars for junitlauncher task ?

Yes, we are, and we do. Via the JUnit 5 standalone distribution "all-deps-are-in" happy jar being copied to the ${ANT_HOME}/lib directory by the build.sh script:

wget --timestamping --continue --directory-prefix "${ant_folder}/lib" "http://central.maven.org/maven2/org/junit/platform/junit-platform-console-standalone/${junit_platform_version}/junit-platform-console-standalone-${junit_platform_version}.jar"

This standalone jar contains all what it is needed to run Jupiter and Vintage (JUnit 3 + 4) tests.

@k-bhavitha
Copy link
Author

Great! Thanks

@sormuras
Copy link
Member

You're welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants