Runtime Checks Testing

T

Trans

While expanding on unit tests for a project, I started to wonder if a
"pre-unit testing" system made any sense --basically a dynamic runtime
checks system. The idea is that for every class, you create a runtime
check subclass, in which methods provide real-time conditions. Then
there would be some mode switch that would automatically use the check
classes vs the regular ones. Eg.

class MyClass
def exclaim(y)
y + "!"
end
end

class MyClass::Check < MyClass
def exclaim(y)
result = super
raise SystemCheckError unless result == "#{y}!"
result
end
end

Now obviously this is a very stupid example, but it presents the basic
idea. This is sort of like double entry book keeping. We are creating
some real-time checks to ensure things are running along as we expect
them too.

What do others think of this sort of thing? How might a system like
this effect unit testing? Could it replace it? Or help reduce the
extent that unit tests are needed? Or simply compliment them? Or is
this a worthless notion all together?

One thing I notice, it has some upside in encouraging good coding by
encouraging small methods.

T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top