Just concentrating on Unity first. Unity is basically a unit testing
framework for C, as such it is used to enable one to write tests
(mainly assertions) that can be run of a given piece/module of code.
Unit testing is part of a Test Driven Development (TDD) approach and
helps control improve code certainty and increase agility,
particularly for code that is developed among groups or communities.
The key is to effectively draw up and code assertions of the codes
behaviour before one actually writes the code. Once a a test harness
is created the code maybe written and tested against it. This should
ideally happen at a micro level small test written followed by small
code written tests run, changes made until tests pass, repeat and
rinse. i.e. it should be gradual and incremental rather than grand,
waterfall based cycles. The tests themselves can be aggregated into
test suites.
As to how unity works it appears to use macros, I am still digging
into its operation.
I won't cover Mock objects yet, but basically thats where it gets more
tricky as we effectively have to simulate hardware.
> On Nov 22, 10:23 am, folknology <a...@folknology.com> wrote:
>> Ok to the subject of testing here are a couple of recommendations:
>>
>> C Unity -http://sourceforge.net/apps/trac/embunity/wiki
>> C Mock -http://cmock.sourceforge.net/
>>
>> Both are C based and thus provide an excellent starting point. Anyone
>> have any alternatives they would like to put forward?
>>
>> The second questions is how these tools work with XC, we would have to
>> drop down to C for testing as they are (I am assuming we could do most
>> of it from C). OR do we take these tools and extend them into XC
>> perhaps?
>>
>> Thoughts?
>>
>> regards
>> Al
>
Russ Ferriday -- Systems Architect & Entrepreneur
CEO Topia Systems Ltd.
ru...@topia.com -- +1 (805) 910 7877 -- www.topia.com
But I say this without having looked, so don't quote me.
In general, forks are expensive, because they dilute the community. If you want a feature that's compatible with an existing project, better to extend or make a plug-in.
--r.
If you take a look at the current SVN head you will see it uses a lot
of function and other pointers that would make it unsuitable for XC
usage. Adding XC support more or less means a rewrite as far as I can
see. It would be the proverbial tail wagging the dog for the Unity
folks, particularly since its aimed at 'C' and not XC ;-)
> In general, forks are expensive, because they dilute the community. If you want a feature that's compatible with an existing project, better to extend or make a plug-in.
This would be a plugin, rewrite is the correct term, unless someone
shows me how we can use void void types, pointers and function
pointers and line numbers in XC.
>
> This would be a plugin, rewrite is the correct term, unless someone
> shows me how we can use void void types, pointers and function
> pointers and line numbers in XC.
OK. Got it!
;)
--r
But the community should be able to help answer these questions for specific projects.
--r.
I'm just thinking about libraries fully inter-operating more than
anything else, and building on each project/library foundation.
We need basically need mechanisms to handle channel based testing in
addition to standard function based tests. In addition we will also
need to find a way to create mock ports and also deal with common
concurrency issues that need to be tested for. Clearly this will be a
project in it's self
Thoughts?
> I have given this some deeper thought this evening and have come to
> the conclusion we are going to have to think very carefully about
> testing with XC. Most unit testing (not even mock objects) relies on
> good functional coverage. In XC's case however, we aren't just dealing
> with imperative function or method calling operations, we are in fact
> operating within concurrent sequential processes, via channels and
> ports, not to mention concurrency. Thus unless someone already has
> experience with this we will have to start from scratch in uncharted
> TDD territory.
Thanks for looking at this in detail, Al.
I agree that it's hard to test CSP. Since each process is potentially a state machine you connect to over one or more channels, we would need the ability to set processes (process networks) to known states, stimulate, then check the outcome.
All of that looks tricky, and will require a lot of work, if it's not to interfere with the system under test.
>
> We need basically need mechanisms to handle channel based testing in
> addition to standard function based tests. In addition we will also
> need to find a way to create mock ports and also deal with common
> concurrency issues that need to be tested for. Clearly this will be a
> project in it's self
Yup.
If you had something as simple as a cache process, you could test it in a test harness before linking it to the rest of your system.
You could also make mock processes, that reacted like the real process.
I tend to write about 30% to 40% extra code, to setup tests for my code. It's a pain, but I can sleep at night.
It makes sense to have whole test setups that then are not loaded into the final product, to help with mem constraints.
--r.