Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » eTrice » etunit(unit testing)
etunit [message #988666] Fri, 30 November 2012 22:50 Go to next message
Tim Born is currently offline Tim BornFriend
Messages: 15
Registered: October 2012
Junior Member
I see etunit in the runtime (org.eclipse.etrice.runtime.java.etunit). This looks like it may be of the xUnit variety. I wasn't able to find any documentation on etunit. Is this something that is generally available? Can I (should I) be using this for unit testing my models?

thanks,
-tim
Re: etunit [message #988747 is a reply to message #988666] Sun, 02 December 2012 16:21 Go to previous messageGo to next message
Thomas Jung is currently offline Thomas JungFriend
Messages: 12
Registered: February 2011
Junior Member
Hi Tim,

we developed etUnit basically for our own needs. There are two basic reasons for that.
1. etUnit works with our runtime environment and does not intruduce theire own test runner.
2. etUnit provides an interface that works for C and Java, so that we are able to test our code generators (C and Java) with common models.

This is the reason why there exists no documentation.

But yes, it is generally available and you can use it to test your own models. You will benefit from the fact that etUnit fits to the runtime model of eTrice. The second aspect is probably not relevant for you.

I attached a test model for you. This model is designed to test some aspects of the FSM generator. You can visit the code to see, how etUnit can be used.

Basically you can write TestActors which sends messages to the Unit (Actors) to test. etUnit can be used to record and check the response messages, so that you can create regression tests.

Let me know if you need more support.

Regards
Thomas
Re: etunit [message #988886 is a reply to message #988747] Mon, 03 December 2012 14:47 Go to previous message
Thomas Schuetz is currently offline Thomas SchuetzFriend
Messages: 31
Registered: January 2010
Member
Hi Tim,

here some more information about etUnit:

The basic idea is to do the tests for actors with actors (possible on all levels of granularity) and to report all as XUnit XML file.

You will find some examples for etUnit in

http://git.eclipse.org/c/etrice/org.eclipse.etrice.git/tree/tests/org.eclipse.etrice.generator.common.tests/models
Have a look at ChoicePointTest.room (git link or attachment)
This test can be generated in Java and C (and soon in C++)

Code and explanations (ChoicePointTest.room):

index.php/fa/12581/0/

- Constructor and Destructor open and close the testcase. You have to memorize the caseId. Be aware that this testcase is a pure whitebox test for testing the codegenerator by generating, compiling and running the code (in case you wonder about this useless statemachine)

- Then you can use the EXPECT_ functions more or less like in JUnit -> a failed EXPECT will not end the testcase, but will stop the reporting (e.g. to avoid problems with EXPECTS in loops)

You will find the interfaces for java and C in:

http://git.eclipse.org/c/etrice/org.eclipse.etrice.git/tree/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/etunit/EtUnit.java

and

http://git.eclipse.org/c/etrice/org.eclipse.etrice.git/tree/runtime/org.eclipse.etrice.runtime.c/src/common/etUnit/etUnit.h

- the EXPECT_ODER is something special for testing the order of execution of code fragements. We use it e.g. for testing the order of entry, exit, action codes in hierarchical FSMs with history (not a simple task). The resultlist defines the order.

- since you can run several testcases concurrently (usually one actor per testcase), we can not directly write the XUnit XML report. So we write the .etunit file first (see ChoicePointTest.etu). Then we sort, merge and transform the etunit files with a little helper into the XUnit (see JavaChoicePointTest.xml). The report can be directly viewed in Eclipse (JUnit view) or be used for the Testreporting of our Hudson Server (https://hudson.eclipse.org/hudson/job/mdt-etrice-nightly/lastCompletedBuild/testReport/org.eclipse.etrice.generator.java.tests/)

The converter code: http://git.eclipse.org/c/etrice/org.eclipse.etrice.git/tree/plugins/org.eclipse.etrice.etunit.converter

You see, we develop everything to work also for continuous integration. Here the CI-Project for eTrice at eclipse.org: https://hudson.eclipse.org/hudson/job/mdt-etrice-nightly/

We also use hudson for our customer projects. Very useful.

For our safety relevant systems (automotive) we are working on a combinatorial testcase generator on model level. This might be also useful for other applications.
With a special test DSL you can specify a model of an expected (not an implemented) behavior and generate testcases to cover and check all branches (including data combinations) of your code.
Here the first Grammar for the test language (in case you like to read in EBNF): http://git.eclipse.org/c/etrice/org.eclipse.etrice.git/tree/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/FSMtest.xtext

If you need anything else, let us know.

- Thomas
Previous Topic:issue with the C TimingService
Next Topic:External Interface
Goto Forum:
  


Current Time: Thu Apr 25 03:32:21 GMT 2024

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

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

Back to the top