विधि 1: -कैसे दावा मायने रखता है परीक्षण इकाई में गणना कर रहे हैं
test.rb
class Test < Test::Unit::TestCase
def test_sample
assert_true(test)
assert_equal(a,b)
end
end
परिणाम: - ३८.३२,९५,३२,५२९ सेकंड में समाप्त हो गया।
1 tests, 2 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
विधि 2: -
test.rb
class Test < Test::Unit::TestCase
require 'helper'
include AssertionHelper
def test_sample
test_assertion
end
end
helper.rb
include Test::Unit::Assertions
module AssertionHelper
def test_assertion
assert_true(test)
assert_equal(a,b)
end
end
परिणाम: -
Finished in 38.329532529 seconds.
1 tests, 2 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
विधि 3: -
test.rb
class Test < Test::Unit::TestCase
require 'helper'
def test_sample
AssertionHelper.test_assertion()
end
end
helper.rb
include Test::Unit::Assertions
module AssertionHelper
def self.test_assertion
assert_true(test)
assert_equal(a,b)
end
end
परिणाम: -
Finished in 38.329532529 seconds.
1 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
विधि 3 का उपयोग कर, मैं दावे के रूप में गिनती हो रही है "2" के बजाय "0"।
क्या मेरे लिए विधि 2 का उपयोग करके 2 के रूप में दावा गिनती संभव है?
क्यों एक अलग मॉड्यूल में जोर रैप करने के लिए ? – Anatoly
@ एनाटोली मेरे पास अधिक परीक्षण फ़ाइलों के लिए सत्यापित होने के लिए सामान्य दावा विवरण हैं। तो मैंने एक सहायक फाइल में आम दावे लगाए हैं और परीक्षण फाइलों से इसे बुलाया है। – karan
test_helper.rb सामान्य कार्यों के लिए है लेकिन ** दावा ** परीक्षणों के भीतर होना चाहिए – Anatoly