Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem is that you are calling your assertions within an instance of another class. If I recall correctly, assert increments the assertion count within its class instance. Therefore your assertion count is being incremented in your RubyDriver instance rather than the RubyTest instance. As a result, you get no assertions reported.</p> <p>You need to do the assertions within the actual test case (ie <code>test_method</code> of RubyTest) that is being run by test/unit.</p> <p>As an example, you could make RubyDriver include your driving logic and logic for retrieving values to test. RubyTest would then call RubyDriver to setup/get values and include your test logic.</p> <pre><code>class RubyTest &lt; Test::Unit::TestCase def test_method # Do some setup using RubyDriver instance driver = RubyDriver.new("/home/pratik/study/UIAutomation/WatirScript.xlsx") driver.call_driver # Use RubyDriver to get some value you want to test some_value_to_test = driver.get_value_to_test # Do the assertion of the value within RubyTest assert_equal(true, some_value_to_test, "Object does not exist") end end </code></pre> <p>An alternative solution might be to pass the test case (RubyTest) to RubyDriver. Then have RubyDriver call the assertion methods using the RubyTest instance.</p> <p>Here is a simplified working example where you can see that your assertion count is correctly updated. Note that the RubyTest instance is passed to RubyDriver and stored in the @testcase variable. All assertions are then run with the context of the @testcase - eg <code>@testcase.assert(false)</code>, which ensures that the original test cases' assertion counts are updated.</p> <pre><code>require 'test/unit' class RubyDriver &lt; Test::Unit::TestCase def initialize(file, testcase) @testcase = testcase super(file) end def action @testcase.assert(false) end end class RubyTest &lt; Test::Unit::TestCase def test_method driver = RubyDriver.new("/home/pratik/study/UIAutomation/WatirScript.xlsx", self) driver.action end end </code></pre> <p>I left the RubyDriver as a sub-class of Test::Unit::TestCase, though it seems a bit odd unless you also have actual tests in the RubyDriver.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload