Test Fixtures

Read time: 8 minutes (2224 words)

In reviewing our work up to this point, we discussed the idea of a “test fixture” into which we could plug a part and run it through a set of tests.

latex/tikz/fixture.png

Thinking about that setup, I decided to try to build a GUI interface that would let us plug in not just parts, but a small set of parts and exercise that, all using the GUI interface we are building. That might be a nicer way to exercise the parts, without relying solely on a set of tests to prove things are working correctly.

Defining a Test

We already have an idea for defining the set of parts we need for a circuit, and the wires needed to hook things together. We also have a way to define how we want signals to “flow” through our machine. All that is missing is a way to identify the inputs we still need to activate (those may be left leave unconnected) and the outputs we want to monitor. My idea is to collect those remaining data items and add them into a single data file that sets everything up.

Here is a definition of the data file I want to build, written in a notation called EBNF, somehting commonly used to define programming languages. The rules for this notation are pretty simple, but we will skip that for the moment.

Reference

https://www.bottlecaps.de/rr/ui

Testing a Component

All Components are simple devices made up of a set of inputs, and outputs. Each component reacts to a single command: tick, which may provide a control signal used to help the component figure out what to do. If you look at the code you wrote for most of the parts, there was not much different in each one. Well, some of them got complicated when we tried to figure out how to get that ``tick method to actually work (remember the decoder?).

Naming the pins was somewhat arbitrary, and forcing a set of names on each device may be something we cna smooth out. In fact, the names are sitting in the specification file we use to wire up a circuit, so why not let that file define the names for all pins on a device.

Let’s try this idea out using a simple inverter component. Here is a specification file, which combines the parts we need, the wires we need (none in this case) and the controls we need to activate this part. It also defies a set of test cases we would like to run with this part plugged in ready for action!