Category "unit-testing"

matching List in any order when mocking method behavior with Mockito

I have a test using Mockito that has a very strange behavior : it works in debug but fails when running normally. After some investigation, I realized it's beca

How to test my update method with Mockito

Here is my test Class: @RunWith(SpringRunner.class) @SpringBootTest public class UpdateRestaurantTest { @MockBean private RestaurantRepository restaura

Comparing LocalDate using Hamcrest in Junit Test Case

I am my unit testing my REST Controller, one of whose field is LocalDate in my Test Case. Code below: @Test public void getByExternalTransactionId() throws E

How to mock Pipe when testing Component

Currently I am overriding providers to use mocked services like this: beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { tcb.ove

How to simulate "No Internet Connection" in Unit/Integration test in C#

I have a component that (by part) uses an internet connection. I wrote some UnitTests to ensure that to component is working. However, I would like to test the

How to use unit testing if there are multiple outputs in java?

How can I test a class that returns the Fibonacci series? I used an iterator for this code. The FibonacciIteratorTest class is below. public class FibonacciIter

How to unit test a component that depends on parameters from ActivatedRoute?

I am unit testing a component that is used to edit an object. The object has an unique id that is used in order to grab the specific object from an array of obj

Mocked values mismatch with MagicMock

I am working on a python project, where we read parquet files from azure datalake and perform the required operations. We have defined a common parquet file rea

Angular 12 setting up Unit test with JEST when running no tests found

Edit: My Jest was not setup on my Angular project properly. so if you are experience this then your Jest was not setup properly, if anyone has a good guide on s

I am getting this error "TypeError: this.reCaptchaApi.render is not a function" when I try to access elements of reactive form for unit testing

I am trying to write unit test cases for registration component in my project, but when I try to access a input ele by ID to test it's placeholder which is in t

Returning multiple objects from a pytest fixture

I am learning how to use pytest by testing a simple event emitter implementation. Basically, it looks like this class EventEmitter(): def __init__(self):

How to test an exception was not thrown with Jest?

The Jest docs do not demonstrate a way of asserting that no exception was thrown, only that one was. expect(() => ...error...).toThrow(error) How do I asse

Using scalamock: Could not find implicit value for evidence parameter of type error

I am writing unit tests for my spark/scala application. I am using scalamock as well to mock objects, specifically Session / Session Factory. In one of my test

How to get the response data in laravel unit testing

I have been trying to work with laravel unit testing. What I wanted was how to get the response data of original. public function testProducts() { $respons

How to get the arguments passed to various calls from call_args_list?

I'm trying to use call_args_list to get the arguments passed to a certain function when it is called multiple times. I'm using this: call_args_list = mock.add_

How to change mock implementation on a per single test basis [Jestjs]

I'd like to change the implementation of a mocked dependency on a per single test basis by extending the default mock's behaviour and reverting it back to the o

How to write the unit test cases for filterpredict function for mat angular table

setupFilter(column: string) { this.dataSource.filterPredicate = (d: Element, filter: string) => { const textToSearch = d[column] && d[column

Mocha + Chai: Continue and try all assertions after failure for the test

I would like the test runner to continue testing the whole it test even after the assertion fails. const { assert } = require('chai'); describe('Test suite', (

MockK "io.mockk.MockKException: no answer found for:" error

Hi i am trying to mock the response i get from a Single observable that gets returned from retrofit using a delegator that my presenter class calls and i am get

Testing a Generator in Python

I programmed a very simple generator in Python 3.4: class Gen: def __init__(self, xml_lines, attribs): #... def _get_values(self, xml_line): # get