Category "unit-testing"

Using Application Insights with Unit Tests?

I have an MVC web app, and I'm using Simple Injector for DI. Almost all my code is covered by unit tests. However, now that I've added some telemetry calls in

JUnit testing got initializationError with java.lang.Exception: No tests found matching

When running JUnit testing , it gave an initializationError: No tests found matching. Like this: prodapi-main-junit initializationError(org.junit.runner.manip

AWS CDK - How to test a resource has one value within an array of values

I have a test suite for an EC2 Redis construct that tests if the resource has particular IAM policies attached. I can test if it has all of the values within on

TDD for an algorithm involving randomness

I would like to try out test-driven development, but the project I am working on involves a lot of randomness and I am very unsure about how I can test it. Here

Using Liquibase to initialize in-memory H2 for unit tests in Spring Boot application

I've used in-mem databases in Spring JPA tests many times, and never had a problem. This time, I have a bit more complex schema to initialize, and that schema m

Django testing rest-framework: APIRequestFactory vs APIClient

Being new to testing i'm looking to test my API in Django (Django-rest-framework). I'm setting up tests for my views, that is my API endpoints. Now looking ov

Testing Svelte components with dynamically imported components in jest (await import)

I'm writing a test in jest for a svelte component which dynamically imports another component. The following snippet is the part where the dynamic import happen

Angular/Jest - Test that the subject has thrown error after setter is called

I have a class that is responsible for setting the theme for my application. I'm trying to test that it throws an error if you give it a theme that it does not

Injecting a Mock using registerConstructor

I've successfully set up a Mock for injection via fruit using .replace(get*Component).with(getMock*Component) like so: #include <gmock/gmock.h> #include

TypeError: (0 , _axios.default) is not a function when use jest.mock('axios') inside a *.test.js file

I try to mock axios module inside my test file like this // mycomponent.test.js import axios from 'axios'; jest.mock('axios', () => ({ get: jest.fn(() =&

TypeError: (0 , _axios.default) is not a function when use jest.mock('axios') inside a *.test.js file

I try to mock axios module inside my test file like this // mycomponent.test.js import axios from 'axios'; jest.mock('axios', () => ({ get: jest.fn(() =&

Grab object values during runtime for creating Mock objects required for writing Unit Test

Consider the below class which needs to be tested, class ToBeTested { Employee _e; public ToBeTested(Employee e) { _e = e; } void Process() {

Get declared fields of java.lang.reflect.Fields in jdk12

In java8 it was possible to access fields of class java.lang.reflect.Fields using e.g. Field.class.getDeclaredFields(); In java12 (starting with java9 ?) thi

Mocking a object using powerMockito.whenNew() and using doNoting(object) but locally created object is calling actual method

public class A { public String[] processMessage(Message msg) { public boolean A(msg) { Utils utils = new Utils(); utils.meth

Why does Android Studio say "Test events were not received"?

I'm trying to unit test in my android application, and this is the simple test tutorial what i'm doing. import static org.junit.Assert.*; import org.junit.Test

How to query by text string which contains html tags using React Testing Library?

Current Working Solution Using this html: <p data-testid="foo">Name: <strong>Bob</strong> <em>(special guest)</em></p> I

xunit test for IFormFile field in Asp.net Core

I have an Asp.net Core method with below definition. [HttpPost] public IActionResult Upload(IFormFile file) { if (file == null || file.Length == 0)

C# custom mail server: receive email through socket on local machine

I'm writing unit testing for email validation. I'm trying to write a very simple POP3 email listener (using sockets) so the email can be sent to my local machin

Unit testing Flask Babel translations

I'd like to do some unit tests to check my flask app translations. I have tried this piece of code: def test_pt_br(self): with app.test_request_context():

Mock redis template

I am facing a issue in mock redis template. Can any one help me to write unit test for below class. @Repository public class CasheRepo { @Autowired pr