Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » eclipse unit tests don't support 'assert'?
eclipse unit tests don't support 'assert'? [message #503079] Thu, 10 December 2009 14:35 Go to next message
Eclipse UserFriend
Currently within a maven project, within a unit test, if I run [run as -> junit test]

it appears that
assert(false)
statements don't fire (they should raise an exception)

Anybody else getting this?
[it's a command line parameter to the JVM].
-r
Re: eclipse unit tests don't support 'assert'? [message #503101 is a reply to message #503079] Thu, 10 December 2009 11:04 Go to previous messageGo to next message
Eclipse UserFriend
Roger Pack wrote:
> Currently within a maven project, within a unit test, if I run [run as
> -> junit test]
>
> it appears that assert(false)
> statements don't fire (they should raise an exception)
>
> Anybody else getting this?
> [it's a command line parameter to the JVM].
> -r


Haven't seen that.

You might want to try putting some debug statements in your test to output the
JVM properties, to see if that option is getting set.

Do you get the expected output if you run the tests in Maven outside of Eclipse?
Re: eclipse unit tests don't support 'assert'? [message #503263 is a reply to message #503079] Fri, 11 December 2009 11:03 Go to previous messageGo to next message
Eclipse UserFriend
Roger Pack wrote:
> Currently within a maven project, within a unit test, if I run [run as
> -> junit test]
>
> it appears that assert(false)
> statements don't fire (they should raise an exception)
Are you talking about JUnit or Java assertions? For Java assertions to
take effect you need to launch with -ea VM argument.

Dani
>
> Anybody else getting this?
> [it's a command line parameter to the JVM].
> -r
Re: eclipse unit tests don't support 'assert'? [message #503347 is a reply to message #503101] Fri, 11 December 2009 15:32 Go to previous messageGo to next message
Eclipse UserFriend
Walter Harley wrote on Thu, 10 December 2009 11:04

> it appears that assert(false)
> statements don't fire within maven unit tests (they should raise an exception)
Haven't seen that.

You might want to try putting some debug statements in your test to output the
JVM properties, to see if that option is getting set.




It appears that eclipse is running the tests with this command line.
javaw -Dfile.encoding=Cp1252 -classpath [...] org.eclipse.jdt.internal.junit.runner.RemoteTestRunner -version 3 -port 2359 -testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader -loaderpluginname org.eclipse.jdt.junit4.runtime -classNames org.familysearch.digitalarchive.dasfinderws.idis.DasServiceI DisImplTest

i.e. I don't see the -ea in there at all.

I'm unsure of any clever way to query the JVM options from within the JVM...

Quote:

Do you get the expected output if you run the tests in Maven outside of Eclipse?



I do. If I run the same tests using maven from the command line, the unit tests fire. I am just scratching my head wondering why eclipse would not add -ea to the command line if I specify "run this file as junit test"

Maven runs its with -ea, netbeans runs it with -ea (because all it does is call maven on it), eclipse doesn't?

Quote:

Are you talking about JUnit or Java assertions? For Java assertions to
take effect you need to launch with -ea VM argument.


Java assertions.

Any thoughts?
-r
Re: eclipse unit tests don't support 'assert'? [message #503387 is a reply to message #503347] Sat, 12 December 2009 12:36 Go to previous message
Eclipse UserFriend
Roger Pack wrote:
> Walter Harley wrote on Thu, 10 December 2009 11:04
>> > it appears that assert(false)
>> > statements don't fire within maven unit tests (they should raise an
>> exception)
>> Haven't seen that.
>>
>> You might want to try putting some debug statements in your test to
>> output the JVM properties, to see if that option is getting set.
>
>
> It appears that eclipse is running the tests with this command line.
> javaw -Dfile.encoding=Cp1252 -classpath [...]
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner -version 3 -port
> 2359 -testLoaderClass
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader
> -loaderpluginname org.eclipse.jdt.junit4.runtime -classNames
> org.familysearch.digitalarchive.dasfinderws.idis.DasServiceI DisImplTest
>
> i.e. I don't see the -ea in there at all.
>
> I'm unsure of any clever way to query the JVM options from within the
> JVM...
>
> Quote:
>> Do you get the expected output if you run the tests in Maven outside
>> of Eclipse?
>
>
> I do. If I run the same tests using maven from the command line, the
> unit tests fire. I am just scratching my head wondering why eclipse
> would not add -ea to the command line if I specify "run this file as
> junit test"
>
> Maven runs its with -ea, netbeans runs it with -ea (because all it does
> is call maven on it), eclipse doesn't?
>
> Quote:
>> Are you talking about JUnit or Java assertions? For Java assertions to
>> take effect you need to launch with -ea VM argument.
>
> Java assertions.
>
> Any thoughts?
> -r
Edit the launch configuration for the unit tests and add the -ea on the
arguments page.
Previous Topic:javamail access restriction error
Next Topic:Ali
Goto Forum:
  


Current Time: Mon Mar 24 16:44:48 EDT 2025

Powered by FUDForum. Page generated in 0.04211 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top