Guest User

Untitled

a guest
Feb 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. require 'test/unit'
  2. require 'test/unit/testresult'
  3.  
  4. # the test to run
  5. require "test/unit/video_test"
  6. ENV['RAILS_ENV'] ||= 'test'
  7.  
  8. class MyTestRunner
  9. attr_reader :methods
  10.  
  11. def initialize(test_file)
  12. @@test_class ||= test_file.classify.constantize
  13.  
  14. @methods = @@test_class.instance_methods - Test::Unit::TestCase.instance_methods
  15. @methods = @methods.select { |m| m =~ /^test_/ }
  16. #logger.info "Methods to test: #{@methods.inspect}"
  17. end
  18.  
  19. def inc
  20. return unless @methods
  21. if @methods.size > 0 and current_test = @methods.shift
  22. test = @@test_class.new(current_test)
  23. results = Test::Unit::TestResult.new
  24. test.run(results) do |t|
  25. #puts t.inspect # debugging
  26. end
  27. f = File.open(Time.now.to_s.gsub(/\W/,'_') + '.log', 'w')
  28. f.write results.inspect
  29. f.close
  30. else
  31. return false
  32. end
  33. end
  34. end
  35.  
  36. obj = MyTestRunner.new('video_test')
  37. obj.inc
  38. obj.inc
  39. obj.inc
  40. # etc
Add Comment
Please, Sign In to add comment