Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » JUnit test not using current validator
JUnit test not using current validator [message #898637] Fri, 27 July 2012 00:22 Go to next message
Brad Riching is currently offline Brad RichingFriend
Messages: 20
Registered: May 2012
Junior Member
Hello,

I have a strange case where I open a new runtime instance of eclipse to test that my new validator check method is working, and it correctly reports the error. However, when I copy and paste the test case source from the eclipse runtime project, into a JUnit test case using external files of my model, the JUnit passes all tests. It's a copy and paste example (that is too huge to copy into this forum) so I have no idea why it wouldn't be working. It seems to me that the *.xtext.tests project is not aware that I made changes to the validator in the *.xtext project. Here's what I've tried:

- Restarting eclipse
- opening and closing projects
- Project -> clean

Here is the part of my validator that I just added to checkPortAssignWidth():

@Check(CheckType.FAST)
public void checkPortAssignWidth(PortAssign p) {
...
	if (p.getConcatenation().isOpen()) {
		EStructuralFeature f = PhdlPackage.Literals.CONCATENATION__OPEN;
		error("Ports may not be open.", p.getConcatenation(), f, -1);
		return;
	}
...
}


The errors are properly reported in the editor UI (see attachment).

I am using eclipselabs/xtext-utils for unit testing.

Here's my testcase which incorrectly does not report any errors, but it should be reporting the same two errors as the editor:
@Test
def void test_atlys() {
	ignoreFormattingDifferences();
	var dir = "TestExamples/atlys/"
	testFile(dir + "s6_devices.phdl", dir + "top.phdl")
}


When I remove the dependencies (the s6_devices.phdl file), top.phdl reports a bunch of linking errors. So I know the framework is actually parsing these files. I am stumped. Does the tests project depend on an actual plugin jar? If so, I have not made one yet of my DSL, so I'm unsure how it would be able to do anything at all if that were the case.

I currently have many other test cases that depend on the state of my validator, and although I had written the entire validator prior to writing THOSE testcases, they all seem to work. It's just that since I've updated my validator, the */xtext.tests project does not seem to be aware of those changes.

Anyone have any idea why my additional check I added to my validator isn't propagating over into the testing framework? (but somehow still is when I open up a runtime instance?)
  • Attachment: editor.png
    (Size: 54.24KB, Downloaded 105 times)
Re: JUnit test not using current validator [message #898860 is a reply to message #898637] Sat, 28 July 2012 11:10 Go to previous message
Brad Riching is currently offline Brad RichingFriend
Messages: 20
Registered: May 2012
Junior Member
For those interested in the solution to this problem: I traced the issue to a bug with Xtext 2.3. I found out that my standalone compiler broke as well as my regression tests in JUnit, so after a bit of research, I used this copy-and-paste example:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=382555

This is a nasty bug for those whose tests suddenly end up breaking when they upgrade to Xtext 2.3.

Best wishes everyone and happy Xtext-ing,

Brad
Previous Topic:XText cross referencing scoping
Next Topic:Updating Xtext 2.2.1 to 2.3.0
Goto Forum:
  


Current Time: Wed Apr 24 22:00:59 GMT 2024

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

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

Back to the top