• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How To Test Negative Paths in the Spring Framework?

 
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I am going to test all the exceptions that can be thrown - provide some error input, if the exception thrown is what I expect, the JUnit test passes. And the project uses the Spring framework. I am not familiar with testing in the Spring framework; henceforth, I am writing to seek help.

Is it true that all I have to do is to write for the "numberFormatAsserter" class? How do I code it? Thank you.



THE_SPRING_CONFIGURATION_FILE.xml
 
Ranch Hand
Posts: 608
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Spring has got an entire chapter dedicated to Testing in its documentation and its pretty easy to follow if you already know JUnit.

Also I don't follow you questions. Looks like you already have your test class ready - so exactly what are you looking for?
 
Natalie Kopple
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
where do I find the chapter that is dedicated to Testing?

I am supposed to write unit tests for all kinds of data errors that developers can think of. If the error is what expected, it should pass the unit test. I simply would like to start with an example; say, the NumberFormatException. My question is how do I code it?

Thank you.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The testing chapter in the docs. Your test looks fine. Are you encountering a problem?
 
Natalie Kopple
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that I was not specific enough. In the Spring framework shown in the earlier posts, how do I let the "null" output to pass the JUnit test? For example, I did something below. But, the JUnit test gives me the java.lang.AssertionError: Expected exception: java.lang.NullPointerException. But the NullPointerException is what I expected. I want to let it pass. In the Java class that is being tested, I have:

In the Spring configuration file:


 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic