tags:

views:

108

answers:

3

In reference to this answer to a Stack Overflow question: what is "bench-testing code"? (Not to be confused with benchmark.)

Presumably it is some kind of code that embedded inside comments and used in the context of QA/testing. But what is it exactly?

A: 

"bench testing" was used a lot in the electronics industry. It refers to testing a circuit on the work bench.

Jay
A: 

"Bench testing code" simply tests the functionality of a section of code.

Placing the actual "bench testing code" in comments provides a much more detailed description of what testing was actually performed.

In my opinion, code should only have a reference (filename) of the "bench testing code" which is maintained elsewhere.

Steven
+1  A: 

In short, it's a synonym for unit test code.

I believe it originates from hardware design:

A hardware developer would create a device, then plug that device into a "test bench", which would then run sample inputs and verify that the output on the pins of the device was correct. It was basically the first (automated?) unit testing.

Flash forward to today, it's a synonym for something that performs unit tests. A TestFixture class in Nunit is analagous to a test bench: You "plug" your class into the TestFixture, and it does its thing similar to how a physical test bench works for hardware.

Josh Kodroff
That makes sense. Could the comments part be a reference to Python's "doctest"?
Peter Mortensen
Looking at it for just a few seconds, I believe Python's doctest is an implementation of a programming language feature called a "contract". A contract consists of statements of what inputs a method will accept and what output will be guaranteed if those inuputs are valid. They're declarative unit tests (and they'll be coming to C# in .NET 4.0 last I heard).
Josh Kodroff