|
Re: Testcoverage of a grammar [message #692613 is a reply to message #691249] |
Mon, 04 July 2011 20:49 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Peter,
you could write individual tests for each parser rule by means of
org.eclipse.xtext.parser.IParser.parse(ParserRule, Reader). I'm not sure
about this approach though. It's generally a better idea to test the
complete grammar and assert the model state afterwards since this is
less error prone.
Java test coverage tools may not be too helpful with the generated
parser class since it contains a lot of catch clauses and the like which
are probably only reached in an editor while typing.
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
On 01.07.11 07:01, Peter B. wrote:
> Hi,
>
> I'm developing systemtests for a program, that uses Xtext to define and
> parse a DSL. The Xtest program was not written by me, so I'm not so
> versed with this framework. Now I want to know, how much of the
> language-elements are covered by my existing tests.
>
> I thought about using the parse trees of my test scripts (written in the
> DSL) and compare them to them with a similar structure generated from
> the grammar.
>
> I can get the parse tree for the tests pretty easy but then, I have no
> idea how to go on.
>
> What might be the best way to do determine the coverage of the grammar?
> Maybe someone of you have an idea to solve this problem and might give
> me a hint to a clean solution.
>
> Thanks!
> Peter
|
|
|
Re: Testcoverage of a grammar [message #695588 is a reply to message #692613] |
Tue, 12 July 2011 04:59 |
Peter B. Messages: 2 Registered: July 2011 |
Junior Member |
|
|
Hi Sebastian,
thanks for the reply, but I think, you got me wrong.
What I have is a DSL used for applying evaluation algorithms on huge datafiles. So, the DSL is quite simple with a syntax as: "OPERATION DATA". Loops and recursions are not possible.
The test-scrips are not written by me but taken from real use cases. So, writing my own test-scripts for each parser rule is not possible. What I want to do is, determining which parts of my DSL are already covered with the commands used in these scripts (and which not). By this, I want to identify rarely used and unused parts of the grammar.
I thought I could use the parse-tree of each test-script to do so. By the parse tree, I can identify the grammar-elements used by the script. Now I first have to determine the complete grammar and then check, which parts of it are covered by the test-script (whith the informations from the parse-tee?).
Any ideas or hints?
Regards,
Peter
|
|
|
Powered by
FUDForum. Page generated in 0.03643 seconds