Replies: 3 comments 13 replies
-
|
IMO, the ability to do virtual or hybrid tests against end-user programs is the real gold here. To that extent, every end-user program could expose a custom service that would make it observable/actionable through jacdac -> unit test framework. This also helps debugability/diagnostics/tracing and what not. Adapters happen to be specialized case where the resulting service is already specified.
Probably want to package test helpers into a separate module to avoid overloading the bus type.
We have an infrastructure to create servers in JS, which talks "packets". It could be extended to be driven by some higher-level mock framework so that the user can define server with specific behaviors for unit tests.
Don't do codegen until you have a very clear picture of what the test API will look like.
Should be test framework agnostic. If we can spinup a virtual bus and run some asserts in a async function, it will fit into all test frameworks.
Hybrid testing is definitely interresting. It gets better: some modules may be use mock behavior, other recorded data and other use real data. |
Beta Was this translation helpful? Give feedback.
-
|
Writing down some design notes on testing, to organize my thinking and iterate on mockups: In software
In digital logic (RTL, chips) hardware
In embeddedThis is based on like 2 hours of websearch with no practical experience, so isn't necessarily representative
For JACDAC
Event handlingAnalogous patterns (probably) exist for register and function testing, but less so for events especially where timing is an important part of the spec and test. Even in Javascript only a small subset of unit test guides talk about events, and the patterns are either writing a custom event handler to set a variable that is later checked by a test, or putting done() in the event. So one design decision:
|
Beta Was this translation helpful? Give feedback.
-
|
Continued hybrid testing ideas:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Project: automated (unit) testing for JACDAC, loosely defined.
Goal: unit testing helps software engineers write code that is more correct, faster. Bring the benefits of unit testing to embedded firmware development, and encourage its use by making writing tests easy, fast, and painless.
Thoughts and suggestions are welcome!
Usage Scenarios
Why JACDAC? JACDAC provides services as a standardized interface, which are a natural point for mocking out the environment. The structured registers and event interfaces can also be more conducive to mocking than arbitrary C/C++ code.
Layers of Testing
Testing Fidelity
Testing Stimulus
Mockups
Button Gesture Detection Adapter, hand-crafted stimulus
Accelerometer Shake Detection Adapter, replay stimulus
Thermostat Application
TBD
Implementation
Test framework: use mocha, since that's what jacdac is currently using.
Primitives
bus.sendPacket(...)myButton.down(),myButton.setState(0)bus.sendEvent(ButtonService, myButtonId, Button.EventClick)- but may be confusing / result in lots of boilerplatebus.expectPacketNow(...)- expects a packet at this instant. Requires precise timing, so for fully-virtual tests only.button.down()returns, so event ordering (fromdown()toexpectPacket) is encoded in the test.TODO: think about implications with async control flows.
bus.expectPacketWithin(..., 200). Checks that the packet is received within the specified time. Used where the user is unsure about timing, eg for shake detection on a captured trace.Overarching Task Tracker
Beta Was this translation helpful? Give feedback.
All reactions