This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
CONTEXT: Given a base test class, which uses the ruby method "inherited(subclass)" to define additional test methods on subclasses, when these subclasses are tested through the NB ruby gui "test file" tool, they will not have all defined tests run. I have 2 test methods defined in the two classes: (actual test case will be attached) base_class: test_shutup_runit (this test only exists to silence rUnit complaints about a subclass of TestCase with no test methods) subclass: test_meta_programming* where * denotes the test method created by "class_eval" in the "inherited(subclass)" method mentioned above. ISSUES: (1) test_meta_programming() does not run, only test_shutup_runit runs. (2) the initialize(suite) method for the subclass does not execute. These two issues do not present themselves when the same test is run on the command line or through rake. My Guess: Perhaps the test case is created using reflection without calling "new()" or "initialize(test_suite)"?
Created attachment 76722 [details] test case to demonstrate focused unit test problem
This bug is triggered when you right click the test and invoke "test file" or "run file"
Thanks for the report, reproduced with the file you attached. I'll have a look at this.
I'm not sure yet how to fix this in NB, but as a workaround you can get your tests working by implementing the inherited method in your test case as follows: class << self alias_method :org_inherited, :inherited def inherited(sub) org_inherited(sub) sub.class_eval do define_method :test_meta_programming do assert_equal "meta", "not meta :(" end end end end The problem with the way it's done in the example you attached is that it doesn't delegate to previous implementations, which causes problems since the NB test runner also needs to implement this method. I'll see if I can somehow come up with another solution, but as long as we need to implement inherited in the test runner it might be a bit challenging.
I suppose this issue doesn't affect that many users, and there is a workaround for this, so I'm adjusting the priority for now - let's increase it again if more folks run into this. Also, I haven't been thinking about this too much lately, but I still can't come up with with a way to fix the NB test runner to avoid the issue.