Monday, 15 August 2011

How to include unit tests in a ruby module? -


I am trying to include unit tests for the module in the same source file as a module, the model after.

#! / Usr / bin / env ruby ​​is required 'test / unit' modulino def modulino_function return 0 end end class ModulinoTest & lt; Test :: Unit :: Test series includes modulin df test_modulino_function assert emble (0, modulino_function) end and

, I can now run the unit-test executing this source file.

But , I am still running when I have to load / load them from any other script. How can this be avoided?

Is there another idiotic way to get it with Ruby, unless this practice is discouraged? Personally, I have never heard of anyone trying to do this in Ruby.

This is definitely not a standard practice, he said that you may be able to take advantage of this trick:

  if __FILE__ == $ 0 # do something .. run the test, one Call method, etc. We are direct   

If the code is executed directly, then if code is executed in the block , then if it is required by any other library or application it occurs.

More Ruby moves are here:


No comments:

Post a Comment