aspose file tools
The moose likes Object Relational Mapping and the fly likes Why isn't an exception being thrown in my JUnit test? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "Why isn Watch "Why isn New topic
Author

Why isn't an exception being thrown in my JUnit test?

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 434
Hi,

I'm using Spring 3.1.1.RELEASE, Hibernate 4.1.0.Final, JUnit 4.8, and JPA 2.0 (hibernate-jpa-2.0-api). I'm trying to write a service test that will intentionally throw an exception, but no exception is getting thrown. I have this entity class



And I'm writing a service test where I set the name to null. But this test passes, when it should throw an exception …




I intentionally set the name to null, but the test goes through without throwing any errors on the save. Why isn't an exception being thrown? Here is my service class



and here is my DAO class …



Thanks for any advice, - Dave
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Why isn't an exception being thrown in my JUnit test?
 
Similar Threads
Help with JPA
org.springframework.dao.EmptyResultDataAccessException: No entity found for query
How to make a crud jsf with ebj without id filed?
How to lookup a EJB 3 session bean from a servlet?
How to query a thirt-party datatabase table with Hibernate CriteriaBuilder/JPA?