Win a copy of Terraform in Action this week in the Cloud forum!
  • 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 ...
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Al Hobbs
  • salvin francis

autowired inherited dependency not getting mocked while executing test case with junit and mockito

Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public abstract class BaseClass {

protected DBproperties dbprop;


public class SampleClass extends BaseClass
private OrderService orderService ;

valdiateOrder(String input){
String config = dbprop.getProperty("config");



public class TestSampleClass{

SampleClass sampleClass ;
private OrderService orderService ;

public void testValidateOrder(){
DBproperties dbprop = mock(DBproperties .class);

am using Junit4 and Mockito for test cases,in the above code dbprop.getProperty("config") throwing null pointer exception because of dbProp as null, please help me out why it was not mocked?
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic