Fwd: I want this test to fail

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Fwd: I want this test to fail

valentin_jacquemin
Hi all,

I set up a test that should be reported as failed but it successed. Concretely I have a method that throws a checked exception which appears in console actually but in the end, db unit says:

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

Although a few lines above:

2047 [main] DEBUG org.hibernate.jdbc.ConnectionManager  - aggressively releasing
 JDBC connection
        at aero.sita.billing.services.UserService.setUserAsCBR(UserService.java:
19)
        at aero.sita.billing.persistance.UserDAOTest.testSetUserCBR(UserDAOTest.
java:25)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at junit.framework.TestCase.runTest(TestCase.java:168)
        at junit.framework.TestCase.runBare(TestCase.java:134)
        at junit.framework.TestResult$1.protect(TestResult.java:110)
        at junit.framework.TestResult.runProtected(TestResult.java:128)
        at junit.framework.TestResult.run(TestResult.java:113)
        at junit.framework.TestCase.run(TestCase.java:124)
        at junit.framework.TestSuite.runTest(TestSuite.java:232)
        at junit.framework.TestSuite.run(TestSuite.java:227)
        at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.
java:83)
        at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.
java:62)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTes
tSet(AbstractDirectoryTestSuite.java:140)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(Ab
stractDirectoryTestSuite.java:127)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:177)

Is it cause of Hibernate that catch the exception maybe? Has anyone encountered the same issue? How can I state to db unit that this test actually failed??

Valentin Jacquemin


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: I want this test to fail

Matthias Gommeringer
Hi Valentin,

could you please provide some more information about your prob (test code, hibernate version, full stack trace)? I guess if the stacktrace you sent is from the "debug" log message then it is definitely not the one that should cause the test to fail. Are you sure your checked exception is really thrown by your "UserService.setUserAsCBR" method in your testcase?

rgds,
matthias


> -----Ursprüngliche Nachricht-----
> Von: "Valentin Jacquemin" <[hidden email]>
> Gesendet: 21.10.09 11:30:52
> An: [hidden email]
> Betreff: [dbunit-user] Fwd: I want this test to fail

Hi all,

>
> I set up a test that should be reported as failed but it successed.
> Concretely I have a method that throws a checked exception which
> appears in console actually but in the end, db unit says:
>
> Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
>
> Although a few lines above:
>
> 2047 [main] DEBUG org.hibernate.jdbc.ConnectionManager - aggressively
> releasing
>  JDBC connection
>  at aero.sita.billing.services.UserService.setUserAsCBR(UserService.
> java:
> 19)
>  at aero.sita.billing.persistance.UserDAOTest.testSetUserCBR(
> UserDAOTest.
> java:25)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImp
> l.
> java:39)
>  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcc
> es
> sorImpl.java:25)
>  at java.lang.reflect.Method.invoke(Method.java:597)
>  at junit.framework.TestCase.runTest(TestCase.java:168)
>  at junit.framework.TestCase.runBare(TestCase.java:134)
>  at junit.framework.TestResult$1.protect(TestResult.java:110)
>  at junit.framework.TestResult.runProtected(TestResult.java:128)
>  at junit.framework.TestResult.run(TestResult.java:113)
>  at junit.framework.TestCase.run(TestCase.java:124)
>  at junit.framework.TestSuite.runTest(TestSuite.java:232)
>  at junit.framework.TestSuite.run(TestSuite.java:227)
>  at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunne
> r.
> java:83)
>  at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSe
> t.
> java:62)
>  at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.
> executeTes
> tSet(AbstractDirectoryTestSuite.java:140)
>  at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.
> execute(Ab
> stractDirectoryTestSuite.java:127)
>  at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
>
> Is it cause of Hibernate that catch the exception maybe? Has anyone
> encountered the same issue? How can I state to db unit that this test
> actually failed??
>
> Valentin Jacquemin
>
> ----------------------------------------------------------------------
> -------- Come build with us! The BlackBerry(R) Developer Conference
> in SF, CA is the only developer event you need to attend this year.
> Jumpstart your developing skills, take BlackBerry mobile applications
> to market and stay ahead of the curve. Join us from November 9 - 12,
> 2009. Register now! http://p.sf.net/sfu/devconference_________________
> ______________________________ dbunit-user mailing list dbunit-user@
> lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/
>
> dbunit-user


_______________________________________________________________
Neu: WEB.DE DSL bis 50.000 kBit/s und 200,- Euro Startguthaben!
http://produkte.web.de/go/02/


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: I want this test to fail

valentin_jacquemin
Hi mathias and thank you for your answer,

My issue is resolved now. The exception was not thrown in the test but in my business code. I am not really sure why it was reporting me that there were no error but now everything works greatly...

Sorry for the noise.

Regards,

Valentin Jacquemin


On Wed, Oct 21, 2009 at 10:31 PM, Matthias Gommeringer <[hidden email]> wrote:
Hi Valentin,

could you please provide some more information about your prob (test code, hibernate version, full stack trace)? I guess if the stacktrace you sent is from the "debug" log message then it is definitely not the one that should cause the test to fail. Are you sure your checked exception is really thrown by your "UserService.setUserAsCBR" method in your testcase?

rgds,
matthias


> -----Ursprüngliche Nachricht-----
> Von: "Valentin Jacquemin" <[hidden email]>
> Gesendet: 21.10.09 11:30:52
> An: [hidden email]
> Betreff: [dbunit-user] Fwd: I want this test to fail

Hi all,
>
> I set up a test that should be reported as failed but it successed.
> Concretely I have a method that throws a checked exception which
> appears in console actually but in the end, db unit says:
>
> Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
>
> Although a few lines above:
>
> 2047 [main] DEBUG org.hibernate.jdbc.ConnectionManager - aggressively
> releasing
>  JDBC connection
>  at aero.sita.billing.services.UserService.setUserAsCBR(UserService.
> java:
> 19)
>  at aero.sita.billing.persistance.UserDAOTest.testSetUserCBR(
> UserDAOTest.
> java:25)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImp
> l.
> java:39)
>  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcc
> es
> sorImpl.java:25)
>  at java.lang.reflect.Method.invoke(Method.java:597)
>  at junit.framework.TestCase.runTest(TestCase.java:168)
>  at junit.framework.TestCase.runBare(TestCase.java:134)
>  at junit.framework.TestResult$1.protect(TestResult.java:110)
>  at junit.framework.TestResult.runProtected(TestResult.java:128)
>  at junit.framework.TestResult.run(TestResult.java:113)
>  at junit.framework.TestCase.run(TestCase.java:124)
>  at junit.framework.TestSuite.runTest(TestSuite.java:232)
>  at junit.framework.TestSuite.run(TestSuite.java:227)
>  at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunne
> r.
> java:83)
>  at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSe
> t.
> java:62)
>  at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.
> executeTes
> tSet(AbstractDirectoryTestSuite.java:140)
>  at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.
> execute(Ab
> stractDirectoryTestSuite.java:127)
>  at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
>
> Is it cause of Hibernate that catch the exception maybe? Has anyone
> encountered the same issue? How can I state to db unit that this test
> actually failed??
>
> Valentin Jacquemin
>
> ----------------------------------------------------------------------
> -------- Come build with us! The BlackBerry(R) Developer Conference
> in SF, CA is the only developer event you need to attend this year.
> Jumpstart your developing skills, take BlackBerry mobile applications
> to market and stay ahead of the curve. Join us from November 9 - 12,
> 2009. Register now! http://p.sf.net/sfu/devconference_________________
> ______________________________ dbunit-user mailing list dbunit-user@
> lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/
>
> dbunit-user


_______________________________________________________________
Neu: WEB.DE DSL bis 50.000 kBit/s und 200,- Euro Startguthaben!
http://produkte.web.de/go/02/


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: I want this test to fail

Roberto Lo Giacco-4
Valentin Jacquemin wrote:
> Hi mathias and thank you for your answer,
>
> My issue is resolved now. The exception was not thrown in the test but
> in my business code. I am not really sure why it was reporting me that
> there were no error but now everything works greatly...
Is it possible you have wrote your tests in the wrong way?

I found some of my less experienced colleagues were writing negative
tests this way:

public void myTestMethod() {
  try {
    // failing test here
  } catch (Exception e) {
    // logging statement here
  }
}

this way tests never fail.

>
> Sorry for the noise.
>
> Regards,
>
> Valentin Jacquemin
>
>
> On Wed, Oct 21, 2009 at 10:31 PM, Matthias Gommeringer
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     Hi Valentin,
>
>     could you please provide some more information about your prob
>     (test code, hibernate version, full stack trace)? I guess if the
>     stacktrace you sent is from the "debug" log message then it is
>     definitely not the one that should cause the test to fail. Are you
>     sure your checked exception is really thrown by your
>     "UserService.setUserAsCBR" method in your testcase?
>
>     rgds,
>     matthias
>
>
>     > -----Ursprüngliche Nachricht-----
>     > Von: "Valentin Jacquemin" <[hidden email]
>     <mailto:[hidden email]>>
>     > Gesendet: 21.10.09 11:30:52
>     > An: [hidden email]
>     <mailto:[hidden email]>
>     > Betreff: [dbunit-user] Fwd: I want this test to fail
>
>     Hi all,
>     >
>     > I set up a test that should be reported as failed but it successed.
>     > Concretely I have a method that throws a checked exception which
>     > appears in console actually but in the end, db unit says:
>     >
>     > Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
>     >
>     > Although a few lines above:
>     >
>     > 2047 [main] DEBUG org.hibernate.jdbc.ConnectionManager -
>     aggressively
>     > releasing
>     >  JDBC connection
>     >  at aero.sita.billing.services.UserService.setUserAsCBR(UserService.
>     > java:
>     > 19)
>     >  at aero.sita.billing.persistance.UserDAOTest.testSetUserCBR(
>     > UserDAOTest.
>     > java:25)
>     >  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     >  at
>     sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImp
>     > l.
>     > java:39)
>     >  at
>     sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcc
>     > es
>     > sorImpl.java:25)
>     >  at java.lang.reflect.Method.invoke(Method.java:597)
>     >  at junit.framework.TestCase.runTest(TestCase.java:168)
>     >  at junit.framework.TestCase.runBare(TestCase.java:134)
>     >  at junit.framework.TestResult$1.protect(TestResult.java:110)
>     >  at junit.framework.TestResult.runProtected(TestResult.java:128)
>     >  at junit.framework.TestResult.run(TestResult.java:113)
>     >  at junit.framework.TestCase.run(TestCase.java:124)
>     >  at junit.framework.TestSuite.runTest(TestSuite.java:232)
>     >  at junit.framework.TestSuite.run(TestSuite.java:227)
>     >  at
>     org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunne
>     > r.
>     > java:83)
>     >  at
>     org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSe
>     > t.
>     > java:62)
>     >  at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.
>     > executeTes
>     > tSet(AbstractDirectoryTestSuite.java:140)
>     >  at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.
>     > execute(Ab
>     > stractDirectoryTestSuite.java:127)
>     >  at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
>     >
>     > Is it cause of Hibernate that catch the exception maybe? Has anyone
>     > encountered the same issue? How can I state to db unit that this
>     test
>     > actually failed??
>     >
>     > Valentin Jacquemin
>     >
>     >
>     ----------------------------------------------------------------------
>     > -------- Come build with us! The BlackBerry(R) Developer Conference
>     > in SF, CA is the only developer event you need to attend this year.
>     > Jumpstart your developing skills, take BlackBerry mobile
>     applications
>     > to market and stay ahead of the curve. Join us from November 9 - 12,
>     > 2009. Register now!
>     http://p.sf.net/sfu/devconference_________________
>     > ______________________________ dbunit-user mailing list dbunit-user@
>     > lists.sourceforge.net <http://lists.sourceforge.net>
>     https://lists.sourceforge.net/lists/listinfo/
>     >
>     > dbunit-user
>
>
>     _______________________________________________________________
>     Neu: WEB.DE <http://WEB.DE> DSL bis 50.000 kBit/s und 200,- Euro
>     Startguthaben!
>     http://produkte.web.de/go/02/
>
>
>     ------------------------------------------------------------------------------
>     Come build with us! The BlackBerry(R) Developer Conference in SF, CA
>     is the only developer event you need to attend this year.
>     Jumpstart your
>     developing skills, take BlackBerry mobile applications to market
>     and stay
>     ahead of the curve. Join us from November 9 - 12, 2009. Register now!
>     http://p.sf.net/sfu/devconference
>     _______________________________________________
>     dbunit-user mailing list
>     [hidden email]
>     <mailto:[hidden email]>
>     https://lists.sourceforge.net/lists/listinfo/dbunit-user
>
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> ------------------------------------------------------------------------
>
> _______________________________________________
> dbunit-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>  


--

  Roberto Lo Giacco

  Chief Technical Officer
  SmartLab s.r.l.
  via Spagna, snc - 87036 Rende (CS) - Italy

  Mobile: +39 392 8765657
  Email: [hidden email]
  Skype: longisland-75
  Web: http://www.smartlab.it 


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user