Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Testcoverage of a grammar(How to determine by systemtests covered elements of the DSL)
Testcoverage of a grammar [message #691249] Fri, 01 July 2011 05:01 Go to next message
Peter B. is currently offline Peter B.Friend
Messages: 2
Registered: July 2011
Junior Member
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 #692613 is a reply to message #691249] Mon, 04 July 2011 20:49 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3108
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 Go to previous message
Peter B. is currently offline Peter B.Friend
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
Previous Topic:Manifest error in project generator wizard
Next Topic:Multiple ANTLR versions using Xtext and third party library in a standalone application
Goto Forum:
  


Current Time: Mon Sep 28 14:51:20 GMT 2020

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

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

Back to the top