• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

The import org.junit.Assert.assertFalse cannot be resolved

 
Ranch Hand
Posts: 770
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi experts,

I am trying to understand what this AntMatcher is about and I chanced upon how this guy brilliantly uses JUnit test to find out if it reads in the various URLs.

Reference
-----------

https://stackoverflow.com/questions/40886239/what-is-the-difference-between-and-pattern-in-spring-boot

So, I thought I would like to see the test result is like in aid of my understanding SpringBoot's AntMatcher.

Now, when I put the whole code in the folder src/test in my SpringBoot web app, I get a bunch of error.  Please see attached.

So far,  I have right click my build path to import JUnit 5 and tried JUit4 but the errors won't go away.

Another thing that puzzled me is the way the syntax is written - using Fun on the method.

I hope someone can tell me what this syntax is about...is it allowed in Java 8  or it is only allowed in higher version ?

Tks.

ide-refuses-to-import.jpg
[Thumbnail for ide-refuses-to-import.jpg]
 
Sheriff
Posts: 16282
271
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What version of junit are you using? The imports for JUnit 5 are different from the imports for earlier versions

On second look, I see you're using JUnit 4 - you need to do a static import for the assertion methods
 
Sheriff
Posts: 22211
117
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I missed that. I saw from the @Test import that JUnit 4 was recognized, it didn't occur to me that the imports weren't static.

@tangara: are you sure the extension is correct? The file says it's a Java source file, but the syntax clearly isn't Java. It looks more like Kotlin.
reply
    Bookmark Topic Watch Topic
  • New Topic