sketchucation logo sketchucation
    • Login
    ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

    MiniTest Testing Framework for SU

    Scheduled Pinned Locked Moved Developers' Forum
    1 Posts 1 Posters 210 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P Offline
      Pierreden
      last edited by

      For those interested, heres what you need to be able to use Ruby 1.9 new unit testing framework in SU.

      1. Download and unpack into su plugin folder

      2. require "minitest/autorun" at the beginning of the script you want to be testing

      3. load /require all modules/classes and testing files in you script

      4. Run MiniTest::Unit.new.run at the end

      5. Unit testing magic!

      It should look something like this:

      require 'minitest/autorun.rb'
      
      class A
      	def say_hi
      		return "Hi!"
      	end
      end
      
      
      class AClassTests < MiniTest;;Unit;;TestCase
      	def setup
      		@a = A.new
      	end
      	
      	def test_say_hi
      		assert_equal @a.say_hi, "Hi!"
      	end
      end
      MiniTest;;Unit.new.run
      

      And Output something like this in the console:

      
      Run options; --seed 27422
      
      # Running tests;
      
      init
      .
      
      Finished tests in 0.047000s, 21.2766 tests/s, 21.2766 assertions/s.
      
      1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
      
      

      To run it again, just run load "yourloadfile.rb" in the ruby console.
      Im not able to get the MiniTest::Unit::autorun feature to work, and this script will run ALL tests loaded into SU, but its seems more than good enough for most.
      Regards
      Pierre

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post
      Buy SketchPlus
      Buy SUbD
      Buy WrapR
      Buy eBook
      Buy Modelur
      Buy Vertex Tools
      Buy SketchCuisine
      Buy FormFonts

      Advertisement