Questions tagged [powermockito]

Use this tag for questions about PowerMockito, a Java Framework that allows the mocking of usually un-mockable types, i.e. statics, and private methods, in conjunction with the Mockito framework. Questions about using PowerMock with EasyMock should be tagged [powermock] instead.

PowerMockito is used in addition with the Java Framework Mockito. PowerMockito's main strength is the ability to mock Static and Private Methods. A good example of PowerMocktio is the ability to mock Singletons which are generally difficult when unit testing.

Heres a great link to starting out with PowerMockito: Using PowerMock with Mockito

1326 questions
-2
votes
1 answer

How to mock com.google.inject.Binder and org.yaml.snakeyaml.Yaml?

According to my requirement I have to increase my code coverage to 80% I some how reached up to 71% but 30% of code is written in main class and the YAML config loader class. Can anyone tell me how to write test cases for following methods:- private…
Anirudh Jadhav
  • 967
  • 1
  • 9
  • 23
-2
votes
1 answer

Unit Testing - how do I stub boolean value from protected method?

So here is the scenario public class Report { public void Generate { if (!isValidDate) { return; } //calling other method } protected boolean isValidDate() { boolean isValid = true; //some…
J.TrLu
  • 65
  • 1
  • 12
-3
votes
1 answer

PowerMockito is not able to access the private method. Why we need power mocking same thing we can achieve by reflection

Power mock framework doing the same thing which i can do by reflection . And test driven environment can be achieve by both for Spring based container.
Santosh
  • 111
  • 2
  • 10
-3
votes
1 answer

How to mock this class?

I'm a student who really needs help with how to mock this class or any part of it. I've tried the general way but it's not working. I think I'm lacking the knowledge and I need help from anyone who knows how to mock these in any way to help me. I…
-3
votes
1 answer

How to verify using Mockito

Class Sample{ int property1; int property2; protected method1(Object1 obj1) { . . obj1.process(new Object2(property1,property2)); . . } } I want to verify that obj1.process is called with certain value. Im happy to provide more…
Insanitee
  • 143
  • 1
  • 1
  • 5
-3
votes
1 answer

Mocking java objects gives class cast exceptions

I have a interface fly and a class duck which implements fly. interface Fly { getWingSize(); } public class Duck implements Fly { @Override int getWingSize(){ return 1; } } In my controller class, when I try to use the…
mistack305
  • 27
  • 4
1 2 3
88
89