Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKenneth Malley
5,557 PointsOptional Message Paramater causing error
When I added the optional message parameter "proper row" and "proper column", I was not able to get the test to finish. I received the error "java: cannot access java.util.function.Supplier class file for java.util.function.Supplier not found
3 Answers
Mateusz Majewski
8,721 PointsTry this, it works for me in JUnit 5 (message is on the last place, not first):
assertEquals(1, loc.getRow(), "proper row");
assertEquals(3, loc.getColumn(), "proper column");
Michael Loria
5,651 PointsNot an expert but I was having the same issue, I think one of the main differences is that I was using JUnit 5 Jupiter and its imports and Craig uses JUnit 4. Using the right imports and annotations helped fix the issue for me.
I think it will work if you use these imports ( which I think comes from JUnit 4) :
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
Here is my code (with the annotations I also used) :
class AlphaNumericChooserTest {
private AlphaNumericChooser chooser;
@Before
void setUp() throws Exception {
chooser = new AlphaNumericChooser(26, 10);
}
@org.junit.Test
void validInputReturnsProperLocation() throws Exception {
AlphaNumericChooser.Location loc = chooser.locationFromInput("B4");
assertEquals( "proper row" , 1, loc.getRow());
assertEquals( "proper column" , 3, loc.getColumn());
}
}
Kenneth Malley
5,557 PointsSame. I was using JUnit 5 as well. But does that mean that optional message parameters are no longer used?
Gianni Onnis
12,014 PointsI'm a beginner and late for answering, but I hope this helps if someone gets here. I'm using JUnit 5 and optional message parameters seem to cause problems when running the tests, so I deleted them and found out that once you run the tests, the method which doesn't pass will be dotted underlined. So if I try with:
assertEquals(2, loc.getRow()); assertEquals(3, loc.getColumn());
the first method will be underlined.