Eclipse bug with JUnit and 'module-info.java'?

77 Views Asked by At

After a combination of Google / Stack Overflow searches I landed on this post which describes my exact problem: StackOverflowQuestion

The post defines this issue is an eclipse bug of version '2022-06': my version, as you can see in the 'Details' tab, comes exactly 1 year later, so I'm wondering if there's something I'm doing wrong, rather than there still being the same bug.

Details:

-MacOS Ventura on M2 Air -Using 'Eclipse IDE': 'About Eclipse':

Version: 2023-06 (4.28.0)

Build id: 20230608-1333

Steps to reproduce (default preferences used)

New Java Project > Finish (Project Name: 'TestProject')

[selected+right-clicked 'src' in 'Package Explorer' view]: New > Package (Name: 'test')

[selected+right-clicked package 'test']: New > Class (Name: 'CoolClass')

[initial modified 'CoolClass' code]:

package test;

import org.junit.Assert;

public class CoolClass {
    @Test
    public void testMethod() {
        int i = 1;
        Assert.assertTrue(i == 1);
    }
}

As expected, there were errors since I hadn't added the 'Junit 4 Library' to the build path. I then proceeded to do this by clicking the lightbulb icon which appeared next to the '@Test' snippet in the editor (as shown here: Image) and clicked on 'add JUnit 4 Library to the build path'.

Despite this, I continued to get these errors:Errors

As stated in the Stack Overflow post I linked above, upon deleting the 'module-info.java' file, these errors totally disappeared.

My questions are:

Is this still a bug or am I missing something? (Surely it can't be since it's been roughly a year right?)

Is having to delete the 'module-info.java' file to use JUnit a problem when coding in java? (I'm still learning to code in Java through the use of Eclipse, so don't have any experience on making a fully fledged 'Project' yet with modules and everything)

Why does removing the 'module-info.java' file tend to resolve certain issues? (I came across this phenomenon whilst reviewing possible duplicate questions proposed by Stack Overflow)

0

There are 0 best solutions below