Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » junit: NamesAreUniqueValidator does not work as eclipse junit but does work in Maven build?
junit: NamesAreUniqueValidator does not work as eclipse junit but does work in Maven build? [message #1863496] Tue, 06 February 2024 13:18 Go to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
I am puzzled. I'm writing very basic unit test cases for parsing.
I've moved to wanting to check some validation.

My DSL is configured with the NamesAreUniqueValidation in the mwe and the GUI editor and command line work and find duplicate names as expected.

However, my junit tests DO NOT find duplicate names when I Run As -> Junit Test.

Why? It's a built in validation that requires nearly zero configuration.

My Junit test DOES find duplicate names when I execute the junit test during a Maven install run. The result.eResource.errors has duplicate name errors in it - as expected - when running Maven.

Why would the behavior be different between Run As Junit Test in Eclipse vs Maven?
Re: junit: NamesAreUniqueValidator does not work as eclipse junit but does work in Maven build? [message #1863497 is a reply to message #1863496] Tue, 06 February 2024 13:33 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
For example, with NamesAreUniqueValidator set:

Hello Xtext!
Hello Xtext!

passes in junit test case validation, but fails in the GUI editor.

Edit: okay, bad example. if I do result.assertNoErrors, I do get an error on Duplicate Xtext in the junit case.

My example seems to be with names that would be qualified names like module1.subModule1 module1.subModule1 - the unit test is not finding these names to be duplicates when running in Eclipse, but is finding duplicates when running in Maven.

[Updated on: Tue, 06 February 2024 13:51]

Report message to a moderator

Re: junit: NamesAreUniqueValidator does not work as eclipse junit but does work in Maven build? [message #1863499 is a reply to message #1863497] Tue, 06 February 2024 13:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14695
Registered: July 2009
Senior Member
did you check the config options on where the validator searches?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: junit: NamesAreUniqueValidator does not work as eclipse junit but does work in Maven build? [message #1863502 is a reply to message #1863499] Tue, 06 February 2024 16:16 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
I've not checked that. Where would I check that?
Re: junit: NamesAreUniqueValidator does not work as eclipse junit but does work in Maven build? [message #1863503 is a reply to message #1863502] Tue, 06 February 2024 17:45 Go to previous messageGo to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
Well I feel dumb.

Looks like things like more as I expect when I Run As -> Junit Plug-in Test.

I was doing Run As -> Junit Test
Re: junit: NamesAreUniqueValidator does not work as eclipse junit but does work in Maven build? [message #1863511 is a reply to message #1863503] Wed, 07 February 2024 05:46 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14695
Registered: July 2009
Senior Member
Checking the class and the latest commits on it

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Rendering problem (?) in runtime Eclipse application
Next Topic:[Xtext] Default values for optional assignments?
Goto Forum:
  


Current Time: Sat Jul 13 13:53:01 GMT 2024

Powered by FUDForum. Page generated in 0.03162 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top