Skip to content

test: upgrade test suite to use latest JUnit version #326

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

Merged
merged 8 commits into from
Sep 30, 2024
Merged

Conversation

algomaster99
Copy link
Member

@algomaster99 algomaster99 commented Sep 19, 2024

Fixes #227

I need to upgrade in order to write good tests. I could use https://github.com/MartinWitt/laughing-train for this problem, but I was not able to build it on my system :/

The refactoring was pretty straightforward. I changed import statements, Ignore is now called Disabled, and reason argument is not the last - after expected and actual.

@algomaster99 algomaster99 requested review from monperrus and removed request for monperrus September 19, 2024 13:42
@algomaster99
Copy link
Member Author

algomaster99 commented Sep 19, 2024

This PR is a reminder that even the simplest of problems can take a bit of your time 😢

The only test that fails it is because of a diff UPDATE: TestCase to junit.framework.TestCase. In the left version, TestCase is imported using wildcard and in the right version, TestCase is imported using its fully qualified name.

With JUnit4 in the classpath, gumtree-spoon resolves that TestCase is same as junit.framework.TestCase since junit.framework,TestCase is an API from JUnit4. However, when we update the JUnit version, spoon model cannot infer the same. If we also include junit.junit:4.13.2, the problem goes away, but I don't want to have dependencies to test resources in pom.xml.

@MartinWitt @I-Al-Istannen, did you see such a bug when porting JUnit 4 to JUnit 5 in spoon?

@algomaster99
Copy link
Member Author

@SirYwell do you have an idea about this?

@SirYwell
Copy link
Member

So in one version the class can be resolved via reflections and in the other spoon uses the no-classpath mode to try to come up with something? I don't think we encountered that in the spoon tests.

But I don't see a way that allows us - while using wildcard imports - to resolve the class properly. I assume you either have to adjust the resources, or the test, or the dependencies.

@algomaster99
Copy link
Member Author

one version the class can be resolved via reflections and in the other spoon uses the no-classpath mode

It seems we use Spoon in default mode as you can see here. Not sure how mode is changing and if it should.
I will try isolating classes for gumtree-spoon diffs from the ones on classpath.

@algomaster99 algomaster99 force-pushed the junit5 branch 2 times, most recently from b696900 to 980e47c Compare September 29, 2024 12:39
@algomaster99
Copy link
Member Author

@monperrus the last few commits fix a failing test because of update in version. Reason: diff computation was taking the junit from classpath. Since it changed from 4 to 5, it caused a change in the diff.
Now, the test is rewritten to use MavenLauncher so it is forced to use junit 4 regardless of what is in the classpath.

You can merge now.

@algomaster99
Copy link
Member Author

Hold on. There are some spurious changes.

@algomaster99
Copy link
Member Author

Well, let's just live with it. Those are IntelliJ defaults. I don't want to change them.

@monperrus monperrus merged commit 1fdf75e into master Sep 30, 2024
1 check passed
@monperrus monperrus deleted the junit5 branch September 30, 2024 04:37
@monperrus
Copy link
Contributor

thanks @algomaster99

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

Successfully merging this pull request may close these issues.

Migrate test suite to JUnit5
3 participants