# Problem using mocha with Test::Unit

**URL:** <https://www.ruby-forum.com/t/problem-using-mocha-with-test-unit/174109>\
**Category:** Ruby\
**Created:** [August 20, 2009, 11:20pm UTC](https://www.ruby-forum.com/t/problem-using-mocha-with-test-unit/174109 "2009-08-20T23:20:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![emilsverige](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/77aa72/32.png) [@emilsverige](https://www.ruby-forum.com/u/emilsverige)\
**Post date:** [August 20, 2009, 11:20pm UTC](https://www.ruby-forum.com/t/problem-using-mocha-with-test-unit/174109/1 "2009-08-20T23:20:19Z")

</div>

I have this simple test:

require “test/unit”  
require ‘mocha’

class TestCanPreload \< Test::Unit::TestCase  
def test\_hello  
assert true  
end  
end

I try to run it in eclipse/aptana, but I get the error:  
Launched class is not compatible with Test::Unit::TestCase

However, if I remove the line “require ‘mocha’”, it works fine.

My environment:  
ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]  
Windows Vista  
Mocha 0.9.7

Any ideas why this happens?

---

<div class="post-metadata">

**Author:** ![emilsverige](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/77aa72/32.png) [@emilsverige](https://www.ruby-forum.com/u/emilsverige)\
**Post date:** [August 22, 2009, 1:07am UTC](https://www.ruby-forum.com/t/problem-using-mocha-with-test-unit/174109/2 "2009-08-22T01:07:33Z")

</div>

The error

2009/8/20 Emil S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> Any ideas why this happens?

The error message doesn’t look Ruby- or Mocha-related. I suspect it is  
specific to Aptana/Eclipse which I do not use.  
Mocha does monkey-patch Test::Unit::TestCase, but it should not change  
it’s  
public API, so I’m not sure what the problem is.

I’d suggest asking on the Aptana/Eclipse mailing list. If it turns out  
there  
is a problem with Mocha, tell us about it on the Mocha mailing list :-

[http://groups.google.com/group/mocha-developer](http://groups.google.com/group/mocha-developer)

---

<div class="post-metadata">

**Author:** ![emilsverige](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/77aa72/32.png) [@emilsverige](https://www.ruby-forum.com/u/emilsverige)\
**Post date:** [August 24, 2009, 3:22pm UTC](https://www.ruby-forum.com/t/problem-using-mocha-with-test-unit/174109/3 "2009-08-24T15:22:00Z")

</div>

James M. wrote:

> The error message doesn’t look Ruby- or Mocha-related. I suspect it is  
> specific to Aptana/Eclipse which I do not use.

You’re probably right. The error message comes from the class  
Test::Unit:UI:Eclipse. It certainly seems that Eclipse/Aptana is the  
cause of the problem.  
Thank you for your help.

Regards Emil
