Mockito Questions
Ad
ModelMapper JUnit Mockito throwing "com.where.where.mapper.ModelMapperService.forRequest()" is null
I'm trying to test a method in service class which uses modelmapper to convert dto to entity, but i'm getting nullpointerexception at this line.
How to mock original XML output to use in test class in Java?
I am writing junit test cases for an application and again and again i have to build dummy document object and set root element and
MockStatic test a static method that returns an int array
My function class a { public static int[] getarray(string text) { return new int[]{0,3}; } } test method:
How to mock a system class for type casting
I have the following code to get the current system memory: val memclass = (context.getsystemservice(context.activity_service) as
NullPointerException when trying to test a void method in Presenter using Mockito
I'm trying to test my app with mockito. it is built using mvp pattern. this is my contract: public interface citiescontract {
How to test a void method within a Presenter using Mockito?
I have a very simple app built using mvp pattern. this is my contract: public interface citiescontract { interface view {
Null Pointer exception passed by test method
method that needs to be tested - located in analyticsserviceimpl.java class public void
RxJava2: .andThen() called even though first Completable emitted error
I have 2 completables in a method, like: completable1.dosomething() .andthen(completable2.dosomethingelse())
Mockito verify fails in second unit test
I am using mockito together to junit to implement unit tests for a class in an android project.the problem is that i call
How to use an android dependency in unit tests?
I'm currently trying out tdd, but cannot get my head around how to use android dependencys in my unit tests. i want to parse the json
Ad
UnfinishedStubbingException
I am newbie in unit test in android. my problem is that i have a helper class for get pixel from dp. this code work good and have a one static
Mockito mocked function returned Null
I'm trying to learn flutter and got stuck on making the test using mockito. i'm trying to implement clean architect to the flutter tutorial
Missing stub error on Mockito in Flutter. Trying to use post of Dio
I’m trying to perform a post request using dio and test it with mockito. but i don’t know why this error is happening, someone knows what is
Riverpod Testing: How to mock state with StateNotifierProvider?
Some of my widgets have conditional ui that show / hide elements depending on state. i am trying to set up tests that find or do not find widgets
How to verify one from many conditions is satisfied on Mockito? Is it possible to verify if one OR another method was called?
On my unit test i want to check if one or another method was called. i can easily verify how many times some methods are called thanks to mockito,
Mock different answers and exceptions after several calls with Mocktail
I was using mocktail for my unit testing and i could not find a way to
Missing stub error on mockito in flutter. Trying to use setString on mocked SharedPreferences
I'm trying to mock sharedpreferences using mockito in my flutter project. here is the error log. package:mockito/src/mock.dart
Unit test for runnable in android using Mockito
How can i write unit test to check if chainoftrusthelper.validate() is executed using mockito verify? please help!!! like
Flutter widget test Clipboard.setData future then never triggered
I am trying to test a clipboard function in my app. when i press a button it should copy my text to the clipboard. when i try to test this
Mocking a DateTime parameter input
Has anyone had issues supplying the any mockito method to a datetime mock method parameter? basically i have this method
Can dart Mockito mock abstract classes?
I am trying to add some unit tests to my dart/flutter library, and one of the dependencies of my unit-under-test is an abstract class:
Ad
Mocking Hive with Mockito Flutter
So basically, i want to check whether i've passed whatever i need to pass to the hiveinterface and box when i want to
Flutter unable to get generate mocks with mockito generateMocks and json_serializable
I am trying to follow this example
Unit test android application with rxjava
I recently jumped in android unit testing and i'm still struggling in writing my unit tests. i'm trying to test my presenter, specifically a
How do you test StreamBuilder in Flutter using Mockito?
I'm trying to test a widget that contains a streambuilder and i'm unable to return data. widget:
Unit Testing with Mockito & Firebase
I am attempting to implement testing for an android app that i'm building. one of the tests involves an interactor file i wrote
How to test nulls using mockito?
I am using mockito 4.1.3 , and here i have some test class:
Argument passed to when() is not a mock! exception thrown with Spring Boot project which doesn't have @SpringBootApplication/main class
My project is a simple spring boot application which doesn't have a main/@springbootapplication class. it is used as a dependency library for
Bad state: No method stub was called from within `when()`
I am trying to test my catch in my signinanonyymous() function. yet, i am constantly getting the error stated in the title. here is my
AndroidX Jetifier Mockito java.lang.SecurityException: SHA-256 digest error for com/samsung/android/sdk/accessory/SAAgentV2.class
I am migrating my app to use androidx. i have
How to mock database in flutter
I tried to mock database to test my local api, i search in official document finding mockito which can work with remote api fine, but also can not
How to mock an object with Guice @Inject?
I have a class a and a class b. public class a{ @inject // guice inject private b b; } the test class
Ad
Mocking SharedPreferences.Editor.putString()
I recently started coding my really first android project using android studio 3.1.2 and sdk 19. i'm writing unit tests for my components
ArgumentCaptor with @Captor annotation in Kotlin
I'm using an
Need example of Robolectric with Mockito to write the unit test case
How to use with mocking (mockito) with robolectric can any one suggest me and i want to write the unit test cases for an api call also, i try with
Using any or anyNamed matchers for nested values with Mockito
I'm trying to pass mockito's argument matchers into nested objects values. i've successfully used something like this so far:
Mockito - `when` execute function instead mock it
I'm kind of new with mockito so i don't know if this behavior is normal or not. this is a simple example class: open class
Testing presenter who contains CompositeDisposable
I tried to create unit test for my presenter class which using rxjava compositedisposable but it always gave a null pointer exception.
Mock Lazy constructor parameter
It is my first question so apologies if i did something wrong. i'm testing a usecase that takes an injected lazy dagger constructor parameter.
How to get mock telephonymanager service android
Actually i want to write some mock unit tests for telephony manger , i am using mockito framework to mock telephony service. i am returning
Testing LiveData using PowerMockRunner
My local unit tests use livedata all the time. normally, when you try to set a value on mutablelivedata you get
Mockito not detecting call on repository of service when using doReturn instead of whenThen
I'm fairly new to mocking, but i've read a lot, also took a course in udemy (not like i'm an expert, very far from it, just saying i've been
Mockiito wrong return value?
Hello i have 2 tests for newinstance() method fragment. but it looks like i'm doing something wrong, because mockito is ignoring my
Ad
Test if another method is called from a class using JUnit or Mockito
I have a class like this public class loginpresimpl implements loginapiinterface.logindatalistener,
How to call AppCompatActivity onCreate in unit test using Mockito
I want to write a simple unit test for the android activity class. the test runs fine while activity is extended, however, when extending
How to mock classes with constructor injection
How to get constructor injection in mockito i have the following
Mocking private method with PowerMock
I'm trying to test the next method: public void methodtotest() { // other stuff privatemethod(false).execute(new void[0]);
Android Unit Test: mocking System.currentTimeMillis()
I'm learning how to write unit tests and i've run into some problems. basically, my method set an alarm based on the system clock, so in
How to mock @injected object in class using Mockito?
I have the following java code: filename: myclass.java import javax.inject.inject; ... public class
Mock kotlin function as parameter in Android
I need to test a kotlin function that accepts another function as parameter. the class looks something like this: class
Unit testing Realm wrapped LiveData with Mockito
I am trying out realm along with android architecture components including livedata. i have been following google's guide to application
How can you test that a function is invoking another function?
I'm new to unit testing, especially in dart/mockito, so maybe i'm approaching this all wrong. i have an authentication system that has a
Mockito NullPointerException when object of Repository is created
Public class driveinteractor implements drivecontract.interactor { private final
Spring Security REST - Unit Tests fail with HttpStatusCode 401 Unauthorized
I have a problem with my unit tests for a spring rest application. in my unit tests i always get the problem that i get 401 "unauthorized" as
Ad
Is there way to mock object without extending with Mock class in Flutter?
I have question about mocking. in kotlin when you use mockito you can do val somemock: mytype = mock() or
Account: Mockito Test Account
I am writing unit test using mockito for a method which returns account object. i am creating a new account as following:
How to write a test method for createNewToken Method?
I am new to this mockito j-unit testing and i want to test my createnewtoken()-method but i cant understand the logic of it.
Mockito NullPointerException thrown instead of custom ExitException
I'm trying to test the functionality of my applicationrunner class which currently depends on a simple cli class. using
Mockito verify invocation error
I would have a problem with the junit tests with mockito. when i try to verify a service i get the error: "actual invocation has different
mockito test invocation into abstract executor
I am writing test on a legacy code, before refactoring it, this means that i should not change that code... i am using spring and
Integration test a manual transaction with transaction template
I am getting null pointer exceptions on my transaction template when i try to test my method that uses manual transactions. when i am running the
How to mock chain of method calls using Mockito
I have a function like this: @override public classa createviewmodel(classb product, classc classcvar)
Tests do not run when dependency on mockito-core present
I've added mockito-core to my dependencies but i seem to be unable to run tests (errors when running) unless i also add
How to mock repository Spring
My test class looks this way and i try to mock repository to return list of real objects. in debug, i see that hashes of mock repository
Unable to autowire RestTemplate for unit test
I have a service which uses an autowired instance of resttemplate like below @service class someapiservice {
Ad
Mockito - how to inject final field marked as @Mock by constructor when using @Spy and @InjectMocks
I have a special case, where i have to mock some fields and use both @mock and @spy for my class, which is under test, because at some tests i
Mockito verify throws UnfinishedVerificationException
In a test, i am using a mockobject: @mock listmultiplechoice<string> listmultiplechoicemock; i try to
NullPointerException from service when use repository
I have a question about the unit test. i am writing a test to check if the service saves the data correctly (i.e. does not make a duplicate)
I can't autowire Service class in Spring Boot Test
I created dao repository that uses jdbc for working with db. i autowired this repository in my service class. then i try to autowire
How to write Junit test for methods with local variables
I have written a method which asks user to press enter to continue and timeouts after some time. i am facing difficulty in writing junit tests for
Mocking chained calls
The class under test is testedclass which holds a field called "inner" from type innerclass. class testedclass{ innerclass
Mockito:: Unit test case for JsonProcessingException when passing object
I have a class as shown below: @getter @setter public class user{ @autowired logger log; private string name;
Mockito Stubbed Spy sometimes calls and sometimes does not call the spied object methods
Question in a @test, how can i achieve both; call a real method from a kotlin class
Error testing firebase login with Mockito
I have login form which sign in the user using firebase and i'm trying to test the login functionality by writing some code and i used mockito to
How to test update methods?
I am new in unit testing and use junit in my java (spring boot) app. i sometimes need to test update methods, but when i search on the web, there
Unit Test: Cannot get value from Service in Java
I am trying to test the following method that gets data from price service. countryserviceimpl:
Ad
Mockito mocking when() for two generic methods of different types
I have two generic objects of class generic<t, r>: generic<typea, typeb> genericone; generic<typeb,
Mock and having real object for testing purposes using Guice
How do i create an object in a guice test module that is used as a mock in one test, but requires to be real object in another. eg.
How to verify arguments passed to a static function with Java JUnit and Mockito (Spring Boot)
I'm new to all the mentioned technologies so it might be a stupid question. we have a spring boot application where we need to write to a
Mockito Mock not returning the defined value
I was on to write some test code for a facebook api wrapper, however, mockito seems not be working as expected:
When using Mockito.spy() to mock a method being called by another method, why do I get a UnnecessaryStubbingException?
I have the following class- public class a { int a; public a() { this.a = 67; } public int get_a() {
How to test throws clause in the class to be tested using Mockito
The flow starts from the controller.callmethod(). it calls a method which throws myexception. myexception is handled by an exception handler
Use the same value in the test and in the method to be tested
Method to be tested: public boolean isvalidstudent(string fname, string lname){ student student = new
Need to mock creation of a object inside a constructor of the class to be tested
I am trying to test a class which is creating a new object inside the constructor. i am using powermock with mockito. public
Injection of a mock object into an object to be tested declared as a field in the test does not work using Mockito?
I have a class and i am injecting a proxy into my service. service service { private serviceproxy proxy; public
Impossible to write integration test controller with DAO mock?
I become crazy, i tried all possible combination of various test runners and possibles annotation for testing, the nearest solution of my need is
Spying an AsyncTask doesn't work
I am testing an asynctask. i want to stub an httpurlconnection to return my mocked object. this is how i do it
Ad
Use result of one mock call in another
How can i use/inject the result of one mock into another? i think i did it in the wrong way the int param is always null i
Gradle separate test classpath dependencies for scala and java tests
I use mockito in my java tests, and have some scala tests. if i include scala testcompile dependency then mockito fail to create a spy when
How to initialize instance for test, when constructor call private method and return exception
In my case, student.java public class student{ private string studentid; public student(string name){ super(name);
String parsed date test in JUnit?
I'm trying to verify a method that contains date parsing implementation. @override public void pasredates(string startdate, string
doReturn doesn't act as proxy but calls my method
I'm implementing some unit testing in my app and i have a dependency that relies in the application context. that dependency returns
Java: mock call to external library to test constructor
I'm trying to unit test classa(string) constructor of following classa class: import externalobject;
Mockito check file exists
I need to create junit test to check if file exists and get from context header and check length, content etc. i found this solutions:
Testing Mono and Flux using Mockito
Im currently writing some basic unit tests for my rest-endpoints. i use mockito
Error:Failed to resolve: org.mockito:mockito-core
When i tried to upgrade mockito for my android project, from 2.8.47 to 2.13.3, i got an error:
Unit test a method with a call to a private callback using Mockito|Android
I am trying to unit test the following method in android: @override public void ontryagain() { mview.showloading();
How to verify to call or not to call a method
Class mockview extends mock implements contactlistviewcontract { @override void onloadcontactscomplete(list<contact> items) {
Ad
test rxjava callback function
I'm trying to test the code written in callback function of one of rxjava operator. here is the original code that i want to test
Mockito with functions in Dart
I have a method that i would like to mock, however when i am trying to verify calls of this method. i get an error that says: used
Ad
Blog Categories
Ad