How to use setup method of TestCase Package

Best Rr_ruby code snippet using TestCase.setup

test-test-case.rb

Source:test-test-case.rb Github

copy

Full Screen

...19 test = test_case.new(:non_existent_test)20 check("Should have caught an invalid test when the method does not exist",21 !test.valid?)22 end23 def setup24 @tc_failure_error = Class.new(TestCase) do25 def test_failure26 assert_block("failure") do27 false28 end29 end30 def test_error31 1 / 032 end33 def test_nested_failure34 nested35 end36 def nested37 assert_block("nested") do38 false39 end40 end41 def return_passed?42 return passed?43 end44 end45 def @tc_failure_error.name46 "TC_FailureError"47 end48 end49 def jruby_backtrace_entry?(entry)50 entry.start_with?("org/jruby/")51 end52 def rubinius_backtrace_entry?(entry)53 entry.start_with?("kernel/")54 end55 def normalize_location(location)56 filtered_location = location.reject do |entry|57 jruby_backtrace_entry?(entry) or58 rubinius_backtrace_entry?(entry)59 end60 filtered_location.collect do |entry|61 entry.sub(/:\d+:/, ":0:")62 end63 end64 def test_add_failed_assertion65 test_case = @tc_failure_error.new(:test_failure)66 assert do67 test_case.passed?68 end69 result = TestResult.new70 faults = []71 result.add_listener(TestResult::FAULT) do |fault|72 faults << fault73 end74 progress = []75 test_case.run(result) do |*arguments|76 progress << arguments77 end78 fault_details = faults.collect do |fault|79 {80 :class => fault.class,81 :message => fault.message,82 :test_name => fault.test_name,83 :location => normalize_location(fault.location),84 }85 end86 assert_equal([87 {88 :class => Failure,89 :message => "failure",90 :test_name => "test_failure(TC_FailureError)",91 :location => [92 "#{__FILE__}:0:in `test_failure'",93 "#{__FILE__}:0:in `#{__method__}'",94 ],95 },96 ],97 fault_details)98 assert do99 not test_case.passed?100 end101 assert_equal([102 [TestCase::STARTED, test_case.name],103 [TestCase::STARTED_OBJECT, test_case],104 [TestCase::FINISHED, test_case.name],105 [TestCase::FINISHED_OBJECT, test_case],106 ],107 progress)108 end109 def test_add_failure_nested110 test_case = @tc_failure_error.new(:test_nested_failure)111 assert do112 test_case.passed?113 end114 result = TestResult.new115 faults = []116 result.add_listener(TestResult::FAULT) do |fault|117 faults << fault118 end119 test_case.run(result) do120 end121 fault_details = faults.collect do |fault|122 {123 :class => fault.class,124 :message => fault.message,125 :test_name => fault.test_name,126 :location => normalize_location(fault.location),127 }128 end129 assert_equal([130 {131 :class => Failure,132 :message => "nested",133 :test_name => "test_nested_failure(TC_FailureError)",134 :location => [135 "#{__FILE__}:0:in `nested'",136 "#{__FILE__}:0:in `test_nested_failure'",137 "#{__FILE__}:0:in `#{__method__}'",138 ],139 },140 ],141 fault_details)142 assert do143 not test_case.passed?144 end145 end146 def jruby?147 defined?(JRUBY_VERSION)148 end149 def rubinius?150 false # TODO151 end152 def cruby?153 (not jruby?) and (not rubinius?)154 end155 def test_add_error156 test_case = @tc_failure_error.new(:test_error)157 assert do158 test_case.passed?159 end160 result = TestResult.new161 faults = []162 result.add_listener(TestResult::FAULT) do |fault|163 faults << fault164 end165 test_case.run(result) do166 end167 fault_details = faults.collect do |fault|168 {169 :class => fault.class,170 :message => fault.message,171 :test_name => fault.test_name,172 :location => normalize_location(fault.location),173 }174 end175 location = []176 location << "#{__FILE__}:0:in `/'" if cruby?177 location << "#{__FILE__}:0:in `test_error'"178 location << "#{__FILE__}:0:in `#{__method__}'"179 assert_equal([180 {181 :class => Error,182 :message => "ZeroDivisionError: divided by 0",183 :test_name => "test_error(TC_FailureError)",184 :location => location,185 },186 ],187 fault_details)188 assert do189 not test_case.passed?190 end191 end192 def test_no_tests193 suite = TestCase.suite194 check("Should have a test suite", suite.instance_of?(TestSuite))195 check("Should have one test", suite.size == 1)196 check("Should have the default test", suite.tests.first.name == "default_test(Test::Unit::TestCase)")197 result = TestResult.new198 suite.run(result) {}199 check("Should have had one test run", result.run_count == 1)200 check("Should have had one test failure", result.failure_count == 1)201 check("Should have had no errors", result.error_count == 0)202 end203 def test_suite204 tc = Class.new(TestCase) do205 def test_succeed206 assert_block {true}207 end208 def test_fail209 assert_block {false}210 end211 def test_error212 1/0213 end214 def dont_run215 assert_block {true}216 end217 def test_dont_run(argument)218 assert_block {true}219 end220 def test221 assert_block {true}222 end223 end224 suite = tc.suite225 check("Should have a test suite", suite.instance_of?(TestSuite))226 check("Should have three tests", suite.size == 3)227 result = TestResult.new228 suite.run(result) {}229 check("Should have had three test runs", result.run_count == 3)230 check("Should have had one test failure", result.failure_count == 1)231 check("Should have had one test error", result.error_count == 1)232 end233 def test_setup_teardown234 tc = Class.new(TestCase) do235 attr_reader(:setup_called, :teardown_called)236 def initialize(test)237 super(test)238 @setup_called = false239 @teardown_called = false240 end241 def setup242 @setup_called = true243 end244 def teardown245 @teardown_called = true246 end247 def test_succeed248 assert_block {true}249 end250 def test_fail251 assert_block {false}252 end253 def test_error254 raise "Error!"255 end256 end257 result = TestResult.new258 test = tc.new(:test_succeed)259 test.run(result) {}260 check("Should have called setup the correct number of times", test.setup_called)261 check("Should have called teardown the correct number of times", test.teardown_called)262 test = tc.new(:test_fail)263 test.run(result) {}264 check("Should have called setup the correct number of times", test.setup_called)265 check("Should have called teardown the correct number of times", test.teardown_called)266 test = tc.new(:test_error)267 test.run(result) {}268 check("Should have called setup the correct number of times", test.setup_called)269 check("Should have called teardown the correct number of times", test.teardown_called)270 check("Should have had two test runs", result.run_count == 3)271 check("Should have had a test failure", result.failure_count == 1)272 check("Should have had a test error", result.error_count == 1)273 end274 def test_assertion_failed_not_called275 tc = Class.new(TestCase) do276 def test_thing277 raise AssertionFailedError.new278 end279 end280 suite = tc.suite281 check("Should have one test", suite.size == 1)282 result = TestResult.new283 suite.run(result) {}284 check("Should have had one test run", result.run_count == 1)285 check("Should have had one assertion failure", result.failure_count == 1)286 check("Should not have any assertion errors but had #{result.error_count}", result.error_count == 0)287 end288 def test_equality289 tc1 = Class.new(TestCase) do290 def test_1291 end292 def test_2293 end294 end295 tc2 = Class.new(TestCase) do296 def test_1297 end298 end299 test1 = tc1.new('test_1')300 test2 = tc1.new('test_1')301 check("Should be equal", test1 == test2)302 check("Should be equal", test2 == test1)303 test1 = tc1.new('test_2')304 check("Should not be equal", test1 != test2)305 check("Should not be equal", test2 != test1)306 test2 = tc1.new('test_2')307 check("Should be equal", test1 == test2)308 check("Should be equal", test2 == test1)309 test1 = tc1.new('test_1')310 test2 = tc2.new('test_1')311 check("Should not be equal", test1 != test2)312 check("Should not be equal", test2 != test1)313 check("Should not be equal", test1 != Object.new)314 check("Should not be equal", Object.new != test1)315 end316 def test_re_raise_exception317 test_case = Class.new(TestCase) do318 def test_raise_interrupt319 raise Interrupt, "from test"320 end321 end322 test = test_case.new("test_raise_interrupt")323 begin324 test.run(TestResult.new) {}325 check("Should not be reached", false)326 rescue Exception327 check("Interrupt exception should be re-raised", $!.class == Interrupt)328 end329 end330 def test_timeout_error331 test_case = Class.new(TestCase) do332 def test_raise_timeout_error333 require "timeout"334 raise Timeout::Error335 end336 end337 test_suite = test_case.suite338 result = TestResult.new339 begin340 test_suite.run(result) {}341 check("Timeout::Error should be handled as error",342 result.error_count == 1)343 rescue Exception344 check("Timeout::Error should not be passed through: #{$!}", false)345 end346 end347 def test_interrupted348 test_case = Class.new(TestCase) do349 def test_fail350 flunk351 end352 def test_nothing353 end354 end355 failed_test = test_case.new(:test_fail)356 failed_test.run(TestResult.new) {}357 check("Should be interrupted", failed_test.interrupted?)358 success_test = test_case.new(:test_nothing)359 success_test.run(TestResult.new) {}360 check("Should not be interrupted", !success_test.interrupted?)361 end362 def test_inherited_test_should_be_ignored363 test_case = Class.new(TestCase) do364 def test_nothing365 end366 end367 sub_test_case = Class.new(test_case) do368 def test_fail369 flunk370 end371 end372 test = test_case.new("test_nothing")373 assert_predicate(test, :valid?)374 test = sub_test_case.new("test_fail")375 assert_predicate(test, :valid?)376 test = sub_test_case.new("test_nothing")377 assert_not_predicate(test, :valid?)378 end379 def test_mixin_test_should_not_be_ignored380 test_module = Module.new do381 def test_nothing382 end383 end384 test_case = Class.new(Test::Unit::TestCase) do385 include test_module386 def test_fail387 flunk388 end389 end390 assert_nothing_thrown do391 test_case.new("test_nothing")392 end393 assert_nothing_thrown do394 test_case.new("test_fail")395 end396 end397 def test_defined_order398 test_case = Class.new(Test::Unit::TestCase) do399 def test_z400 end401 def test_1402 end403 def test_a404 end405 end406 test_case.test_order = :defined407 assert_equal(["test_z", "test_1", "test_a"],408 test_case.suite.tests.collect {|test| test.method_name})409 end410 def test_declarative_style411 test_case = Class.new(Test::Unit::TestCase) do412 test "declarative style test definition" do413 end414 test "include parenthesis" do415 end416 test "1 + 2 = 3" do417 end418 end419 test_case.test_order = :defined420 assert_equal(["test: declarative style test definition",421 "test: include parenthesis",422 "test: 1 + 2 = 3"],423 test_case.suite.tests.collect {|test| test.method_name})424 assert_equal(["declarative style test definition",425 "include parenthesis",426 "1 + 2 = 3"],427 test_case.suite.tests.collect {|test| test.description})428 end429 def test_test_mark430 test_case = Class.new(Test::Unit::TestCase) do431 test432 def my_test_method433 end434 end435 test_case.test_order = :defined436 assert_equal(["my_test_method"],437 test_case.suite.tests.collect {|test| test.method_name})438 end439 def test_redefine_method440 test_case = Class.new(Test::Unit::TestCase) do441 self.test_order = :alphabetic442 def test_name443 end444 alias_method :test_name2, :test_name445 def test_name446 end447 end448 suite = test_case.suite449 assert_equal(["test_name", "test_name2"],450 suite.tests.collect {|test| test.method_name})451 result = TestResult.new452 suite.run(result) {}453 assert_equal("2 tests, 0 assertions, 0 failures, " +454 "0 errors, 0 pendings, 0 omissions, 1 notifications",455 result.summary)456 end457 def test_data_driven_test458 test_case = Class.new(TestCase) do459 def test_with_data(data)460 end461 end462 test = test_case.new("test_with_data")463 assert_not_predicate(test, :valid?)464 test.assign_test_data("label1", :test_data1)465 assert_predicate(test, :valid?)466 end467 def test_data_driven_test_without_parameter468 test_case = Class.new(TestCase) do469 data("label" => "value")470 def test_without_parameter471 end472 end473 suite = test_case.suite474 assert_equal(["test_without_parameter"],475 suite.tests.collect {|test| test.method_name})476 result = TestResult.new477 suite.run(result) {}478 assert_equal("1 tests, 0 assertions, 0 failures, " +479 "0 errors, 0 pendings, 0 omissions, 1 notifications",480 result.summary)481 end482 private483 def check(message, passed)484 add_assertion485 raise AssertionFailedError.new(message) unless passed486 end487 class TestTestDefined < self488 class TestNoQuery < self489 def test_no_test490 test_case = Class.new(TestCase) do491 end492 assert_false(test_case.test_defined?({}))493 end494 def test_have_def_style_test495 test_case = Class.new(TestCase) do496 def test_nothing497 end498 end499 assert_true(test_case.test_defined?({}))500 end501 def test_have_method_style_test502 test_case = Class.new(TestCase) do503 test "nothing" do504 end505 end506 assert_true(test_case.test_defined?({}))507 end508 end509 class TestPath < self510 class TestDefStyle < self511 def test_base_name512 test_case = Class.new(TestCase) do513 def test_nothing514 end515 end516 base_name = File.basename(__FILE__)517 assert_true(test_case.test_defined?(:path => base_name))518 end519 def test_absolute_path520 test_case = Class.new(TestCase) do521 def test_nothing522 end523 end524 assert_true(test_case.test_defined?(:path => __FILE__))525 end526 def test_not_match527 test_case = Class.new(TestCase) do528 def test_nothing529 end530 end531 assert_false(test_case.test_defined?(:path => "nonexistent.rb"))532 end533 end534 class TestMethodStyle < self535 def test_base_name536 test_case = Class.new(TestCase) do537 test "nothing" do538 end539 end540 base_name = File.basename(__FILE__)541 assert_true(test_case.test_defined?(:path => base_name))542 end543 def test_absolute_path544 test_case = Class.new(TestCase) do545 test "nothing" do546 end547 end548 assert_true(test_case.test_defined?(:path => __FILE__))549 end550 def test_not_match551 test_case = Class.new(TestCase) do552 test "nothing" do553 end554 end555 assert_false(test_case.test_defined?(:path => "nonexistent.rb"))556 end557 end558 end559 class TestLine < self560 class TestDefStyle < self561 def test_before562 line_before = nil563 test_case = Class.new(TestCase) do564 line_before = __LINE__565 def test_nothing566 end567 end568 assert_false(test_case.test_defined?(:line => line_before))569 end570 def test_def571 line_def = nil572 test_case = Class.new(TestCase) do573 line_def = __LINE__; def test_nothing574 end575 end576 assert_true(test_case.test_defined?(:line => line_def))577 end578 def test_after579 line_after = nil580 test_case = Class.new(TestCase) do581 def test_nothing582 end583 line_after = __LINE__584 end585 assert_true(test_case.test_defined?(:line => line_after))586 end587 def test_child588 child_test_case = nil589 line_child = nil590 parent_test_case = Class.new(TestCase) do591 test "parent" do592 end593 child_test_case = Class.new(self) do594 line_child = __LINE__; test "child" do595 end596 end597 end598 assert_equal([599 false,600 true,601 ],602 [603 parent_test_case.test_defined?(:line => line_child),604 child_test_case.test_defined?(:line => line_child),605 ])606 end607 end608 class TestMethodStyle < self609 def test_before610 line_before = nil611 test_case = Class.new(TestCase) do612 line_before = __LINE__613 test "nothing" do614 end615 end616 assert_false(test_case.test_defined?(:line => line_before))617 end618 def test_method619 line_method = nil620 test_case = Class.new(TestCase) do621 line_method = __LINE__; test "nothing" do622 end623 end624 assert_true(test_case.test_defined?(:line => line_method))625 end626 def test_after627 line_after = nil628 test_case = Class.new(TestCase) do629 test "nothing" do630 end631 line_after = __LINE__632 end633 assert_true(test_case.test_defined?(:line => line_after))634 end635 def test_child636 child_test_case = nil637 line_child = nil638 parent_test_case = Class.new(TestCase) do639 test "parent" do640 end641 child_test_case = Class.new(self) do642 line_child = __LINE__; test "child" do643 end644 end645 end646 assert_equal([647 false,648 true,649 ],650 [651 parent_test_case.test_defined?(:line => line_child),652 child_test_case.test_defined?(:line => line_child),653 ])654 end655 def test_with_setup656 line = nil657 test_case = Class.new(TestCase) do658 setup do659 end660 line = __LINE__; test "with setup" do661 end662 end663 assert do664 test_case.test_defined?(:line => line,665 :method_name => "test: with setup")666 end667 end668 end669 end670 class TestMethodName < self671 class TestDefStyle < self672 def test_match673 test_case = Class.new(TestCase) do674 def test_nothing675 end676 end677 query = {:method_name => "test_nothing"}678 assert_true(test_case.test_defined?(query))679 end680 def test_not_match681 test_case = Class.new(TestCase) do682 def test_nothing683 end684 end685 query = {:method_name => "test_nonexistent"}686 assert_false(test_case.test_defined?(query))687 end688 end689 class TestMethodStyle < self690 def test_match691 test_case = Class.new(TestCase) do692 test "nothing" do693 end694 end695 query = {:method_name => "test: nothing"}696 assert_true(test_case.test_defined?(query))697 end698 def test_not_match699 test_case = Class.new(TestCase) do700 test "nothing" do701 end702 end703 query = {:method_name => "test: nonexistent"}704 assert_false(test_case.test_defined?(query))705 end706 end707 end708 class TestCombine < self709 class TestDefStyle < self710 def test_line_middle711 line_middle = nil712 test_case = Class.new(TestCase) do713 def test_before714 end715 line_middle = __LINE__716 def test_after717 end718 end719 query = {720 :path => __FILE__,721 :line => line_middle,722 :method_name => "test_before",723 }724 assert_true(test_case.test_defined?(query))725 end726 def test_line_after_def727 line_after_def = nil728 test_case = Class.new(TestCase) do729 def test_before730 end731 line_after_def = __LINE__; def test_after732 end733 end734 query = {735 :path => __FILE__,736 :line => line_after_def,737 :method_name => "test_before",738 }739 assert_false(test_case.test_defined?(query))740 end741 end742 class TestMethodStyle < self743 def test_line_middle744 line_middle = nil745 test_case = Class.new(TestCase) do746 test "before" do747 end748 line_middle = __LINE__749 test "after" do750 end751 end752 query = {753 :path => __FILE__,754 :line => line_middle,755 :method_name => "test: before",756 }757 assert_true(test_case.test_defined?(query))758 end759 def test_line_after_method760 line_after_method = nil761 test_case = Class.new(TestCase) do762 test "before" do763 end764 line_after_method = __LINE__; test "after" do765 end766 end767 query = {768 :path => __FILE__,769 :line => line_after_method,770 :method_name => "test: before",771 }772 assert_false(test_case.test_defined?(query))773 end774 end775 end776 end777 class TestSubTestCase < self778 class TestName < self779 def test_anonymous780 test_case = Class.new(TestCase)781 sub_test_case = test_case.sub_test_case("sub test case") do782 end783 assert_equal("sub test case", sub_test_case.name)784 end785 def test_named786 test_case = Class.new(TestCase)787 def test_case.name788 "ParentTestCase"789 end790 sub_test_case = test_case.sub_test_case("sub test case") do791 end792 assert_equal("ParentTestCase::sub test case", sub_test_case.name)793 end794 end795 def test_suite796 test_case = Class.new(TestCase)797 sub_test_case = test_case.sub_test_case("sub test case") do798 def test_nothing799 end800 end801 test_method_names = sub_test_case.suite.tests.collect do |test|802 test.method_name803 end804 assert_equal(["test_nothing"], test_method_names)805 end806 def test_duplicated_name807 test_case = Class.new(TestCase) do808 def test_nothing809 end810 end811 sub_test_case = test_case.sub_test_case("sub test case") do812 def test_nothing813 end814 end815 test_method_names = test_case.suite.tests.collect do |test|816 test.method_name817 end818 sub_test_method_names = sub_test_case.suite.tests.collect do |test|819 test.method_name820 end821 assert_equal([822 ["test_nothing"],823 ["test_nothing"],824 ],825 [826 test_method_names,827 sub_test_method_names,828 ])829 end830 end831 class TestStartupShutdown < self832 class TestOrder < self833 module CallLogger834 def called835 @@called ||= []836 end837 end838 def call_order(test_case)839 test_case.called.clear840 test_suite = test_case.suite841 test_suite.run(TestResult.new) {}842 test_case.called843 end844 class TestNoInheritance < self845 def setup846 @test_case = Class.new(TestCase) do847 extend CallLogger848 class << self849 def startup850 called << :startup851 end852 def shutdown853 called << :shutdown854 end855 end856 def setup857 self.class.called << :setup858 end859 def teardown860 self.class.called << :teardown861 end862 def test1863 end864 def test2865 end866 end867 end868 def test_call_order869 assert_equal([870 :startup,871 :setup, :teardown,872 :setup, :teardown,873 :shutdown,874 ],875 call_order(@test_case))876 end877 end878 class TestInheritance < self879 def setup880 @original_descendants = TestCase::DESCENDANTS.dup881 TestCase::DESCENDANTS.clear882 @parent_test_case = Class.new(TestCase) do883 extend CallLogger884 self.test_order = :alphabetic885 class << self886 def startup887 called << :startup_parent888 end889 def shutdown890 called << :shutdown_parent891 end892 end893 def setup894 self.class.called << :setup_parent895 end896 def teardown897 self.class.called << :teardown_parent898 end899 def test1_parent900 self.class.called << :test1_parent901 end902 def test2_parent903 self.class.called << :test2_parent904 end905 end906 @child_test_case = Class.new(@parent_test_case) do907 class << self908 def startup909 called << :startup_child910 end911 def shutdown912 called << :shutdown_child913 end914 end915 def setup916 self.class.called << :setup_child917 end918 def teardown919 self.class.called << :teardown_child920 end921 def test1_child922 self.class.called << :test1_child923 end924 def test2_child925 self.class.called << :test2_child926 end927 end928 end929 def teardown930 TestCase::DESCENDANTS.replace(@original_descendants)931 end932 def test_call_order933 collector = Collector::Descendant.new934 test_suite = collector.collect935 test_suite.run(TestResult.new) {}936 called = @parent_test_case.called937 assert_equal([938 :startup_parent,939 :setup_parent, :test1_parent, :teardown_parent,940 :setup_parent, :test2_parent, :teardown_parent,941 :startup_child,942 :setup_child, :test1_child, :teardown_child,943 :setup_child, :test2_child, :teardown_child,944 :shutdown_child,945 :shutdown_parent,946 ],947 called)948 end949 end950 end951 class TestError < self952 def run_test_case(test_case)953 test_suite = test_case.suite954 result = TestResult.new955 test_suite.run(result) {}956 result957 end...

Full Screen

Full Screen

test_framework_detection_test.rb

Source:test_framework_detection_test.rb Github

copy

Full Screen

...28 end29 if CURRENT_APPRAISAL_NAME == 'minitest_5_x'30 should 'detect Minitest 5.x when it is loaded standalone' do31 assert_integration_with 'Minitest::Test', 'Minitest::Unit::TestCase',32 setup: <<-RUBY33 require 'minitest/autorun'34 RUBY35 end36 end37 if CURRENT_APPRAISAL_NAME == 'minitest_4_x'38 should 'detect Minitest 4.x when it is loaded standalone' do39 assert_integration_with 'MiniTest::Unit::TestCase',40 setup: <<-RUBY41 require 'minitest/autorun'42 RUBY43 end44 end45 if CURRENT_APPRAISAL_NAME == 'test_unit'46 should 'detect the test-unit gem when it is loaded standalone' do47 assert_integration_with 'Test::Unit::TestCase',48 setup: <<-RUBY49 require 'test/unit'50 RUBY51 end52 end53 def assert_integration_with(*test_cases)54 assert_test_cases_are_detected(*test_cases)55 assert_our_api_is_available_in_test_cases(*test_cases)56 end57 def assert_integration_with_rails_and(*test_cases)58 test_cases = ['ActiveSupport::TestCase'] | test_cases59 options = test_cases.last.is_a?(Hash) ? test_cases.pop : {}60 options[:setup] = <<-RUBY61 require 'rails/all'62 require 'rails/test_help'63 ActiveRecord::Base.establish_connection(64 adapter: 'sqlite3',65 database: ':memory:'66 )67 RUBY68 args = test_cases + [options]69 assert_integration_with(*args)70 end71 def assert_test_cases_are_detected(*expected_test_cases)72 options = expected_test_cases.last.is_a?(Hash) ? expected_test_cases.pop : {}73 setup = options[:setup] || ''74 output = execute(file_that_detects_test_framework_test_cases([setup]))75 actual_test_cases = output.split("\n").first.split(', ')76 assert_equal expected_test_cases, actual_test_cases77 end78 def file_that_detects_test_framework_test_cases(mixins)79 <<-RUBY80 #{require_gems(mixins)}81 require 'yaml'82 test_cases = Shoulda::Context.test_framework_test_cases.map { |test_case| test_case.to_s }83 puts test_cases.join(', ')84 RUBY85 end86 def require_gems(mixins)87 <<-RUBY88 ENV['BUNDLE_GEMFILE'] = "#{PROJECT_DIR}/gemfiles/#{CURRENT_APPRAISAL_NAME}.gemfile"89 require 'bundler'90 Bundler.setup91 #{mixins.join("\n")}92 require 'shoulda-context'93 RUBY94 end95 def assert_our_api_is_available_in_test_cases(*test_cases)96 options = test_cases.last.is_a?(Hash) ? test_cases.pop : {}97 setup = options[:setup] || ''98 test_cases.each do |test_case|99 output = execute(file_that_runs_a_test_within_test_case(test_case, [setup]))100 assert_match /1 (tests|runs)/, output101 assert_match /1 assertions/, output102 assert_match /0 failures/, output103 assert_match /0 errors/, output104 end105 end106 def file_that_runs_a_test_within_test_case(test_case, mixins)107 <<-RUBY108 #{require_gems(mixins)}109 class FrameworkIntegrationTest < #{test_case}110 context 'a context' do111 should 'have a test' do112 assert_equal true, true113 end...

Full Screen

Full Screen

setup

Using AI Code Generation

copy

Full Screen

1 @driver.get(@base_url + "/")2 @driver.find_element(:id, "gbqfq").clear3 @driver.find_element(:id, "gbqfq").send_keys "selenium"4 @driver.find_element(:id, "gbqfb").click5 @driver.find_element(:link, "Selenium - Web Browser Automation").click6 @driver.find_element(:link, "Download").click7 @driver.find_element(:link, "Download").click8 @driver.get(@base_url + "/")9 @driver.find_element(:id, "gbqfq").clear10 @driver.find_element(:id, "gbqfq").send_keys "selenium"11 @driver.find_element(:id, "gbqfb").click12 @driver.find_element(:link, "Selenium - Web Browser Automation").click13 @driver.find_element(:link, "Download").click14 @driver.find_element(:link, "Download").click

Full Screen

Full Screen

setup

Using AI Code Generation

copy

Full Screen

1irb(main):001:0> require 'test/unit'2irb(main):002:0> class Test::Unit::TestCase3irb(main):003:1> def setup4irb(main):004:2> puts "setup"5irb(main):005:2> end6irb(main):006:1> end7irb(main):007:0> class Test1 < Test::Unit::TestCase8irb(main):008:1> def test_19irb(main):009:2> puts "test_1"10irb(main):010:2> end11irb(main):011:1> end12irb(main):012:0> class Test2 < Test::Unit::TestCase13irb(main):013:1> def test_214irb(main):014:2> puts "test_2"15irb(main):015:2> end16irb(main):016:1> end17irb(main):017:0> Test1.new.test_118irb(main):018:0> Test2.new.test_2

Full Screen

Full Screen

setup

Using AI Code Generation

copy

Full Screen

1 assert_equal(1, @a)2 assert_equal(1, @a)3 assert_equal(1, @a)4 assert_equal(1, @a)5 assert_equal(1, @a)6 assert_equal(1, @a)

Full Screen

Full Screen

setup

Using AI Code Generation

copy

Full Screen

1 @num = SimpleNumber.new(2)2 assert_equal(4, @num.add(2))3 assert_equal(4, @num.multiply(2))4 @num = SimpleNumber.new(2)5 assert_equal(4, @num.add(2))6 assert_equal(4, @num.multiply(2))7 @num = SimpleNumber.new(2)8 assert_equal(4, @num.add(2))9 assert_equal(4, @num.multiply(2))10 @num = SimpleNumber.new(2)11 assert_equal(4, @num.add(2))12 assert_equal(4, @num.multiply(2))13 @num = SimpleNumber.new(2)14 assert_equal(4, @num.add(2))15 assert_equal(4, @num.multiply(2))

Full Screen

Full Screen

setup

Using AI Code Generation

copy

Full Screen

1 @browser.find_element(:name, 'q').send_keys 'Selenium'2 @browser.find_element(:name, 'btnG').click3 @browser.find_element(:name, 'q').send_keys 'Ruby'4 @browser.find_element(:name, 'btnG').click

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Rr_ruby automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful