Class | ZenTest |
In: |
lib/zentest.rb
|
Parent: | Object |
ZenTest scans your target and unit-test code and writes your missing code based on simple naming rules, enabling XP at a much quicker pace. ZenTest only works with Ruby and Test::Unit.
ZenTest uses the following rules to figure out what code should be generated:
See ZenTestMapping for documentation on method naming.
VERSION | = | '3.11.1' |
Process all the supplied classes for methods etc, and analyse the results. Generate the skeletal code and eval it to put the methods into the runtime environment.
Runs ZenTest over all the supplied files so that they are analysed and the missing methods have skeleton code written.
Walk each known class and test that each method has a test method Then do it in the other direction…
Checks, for the given class klassname, that each method has a corrsponding test method. If it doesn‘t this is added to the information for that class
For the given test class testklassname, ensure that all the test methods have corresponding (normal) methods. If not, add them to the information about that class.
Generate the name of a testclass from non-test class so that Foo::Blah => TestFoo::TestBlah, etc. It the name is already a test class, convert it the other way.
Using the results gathered during analysis generate skeletal code with methods raising NotImplementedError, so that they can be filled in later, and so the tests will fail to start with.
obtain the class klassname, either from Module or using ObjectSpace to search for it.
Return the methods for class klass, as a hash with the method nemas as keys, and true as the value for all keys. Unless full is true, leave out the methods for Object which all classes get.
Get the public instance, class and singleton methods for class klass. If full is true, include the methods from Kernel and other modules that get included. The methods suite, new, pretty_print, pretty_print_cycle will not be included in the resuting array.
looks up the methods and the corresponding test methods in the collection already built. To reduce duplication and hide implementation details.
Does all the work of finding a class by name, obtaining its methods and those of its superclass. The full parameter determines if all the methods including those of Object and mixed in modules are obtained (true if they are, false by default).
Work through files, collecting class names, method names and assertions. Detects ZenTest (SKIP|FULL) comments in the bodies of classes. For each class a count of methods and test methods is kept, and the ratio noted.