SpoonLabs / gumtree-spoon-ast-diff

Computes the AST difference (aka edit script) between two Spoon Java source code abstract syntax trees
http://hal.archives-ouvertes.fr/hal-01054552
Apache License 2.0
161 stars 42 forks source link

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

Closed algomaster99 closed 1 month ago

algomaster99 commented 2 months ago

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 commented 2 months ago

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

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 commented 2 months ago

@SirYwell do you have an idea about this?

SirYwell commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

@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 commented 2 months ago

Hold on. There are some spurious changes.

algomaster99 commented 2 months ago

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

monperrus commented 1 month ago

thanks @algomaster99