Category "unit-testing"

How to apply test-driven development for storing data on db?

Let us assume that the next feature that I have to develop is to store some data on a database. Following the TDD paradigm, I have to first write a failing test

NullPointerException when MockMvc performed in unit test

I'm trying to write a Java unit test but not sure where I'm going wrong. Likely a lack of understanding. This is my test so far: @Test public void getURL() thro

Simplifying AWS SDK GO v2 testing/mocking

Amazon has a super useful article describing how to unit test AWS SDK Go v2. I understand their motivation to depart from the "old" way of unit testing the v1

How to make MSTest grab all console output from unit test? Output behind WebHost.CreateDefaultBuilder() goes missing (VS2022, .NET 6, MSTest 2.2.10)

I'm creating an integration test for a Web API, so I'm starting an entire application in a unit test using WebHost.CreateDefaultBuilder() and the usual setup bi

How to distinguish between two calls of the same method based on the argumetns?

I'm using sinon to stub functions of the Google Drive in my NodeJS application. I do two different calls of the create method under the same test (I can't do re

Xunit in asp.net core

I'm new at asp.net and moq and xunit test, I want to create a test case for my asp.net project. I have the service file that is CRUD action, I have been written

Is there a way of formatting failed output from Laravel's assertSee() test?

Laravel has several built-in assertions that allow you to query the Response from a Request. public function testWebpage() { $response = $this-&

How can I represent map[string][]byte? [closed]

I would like to create a map, but I am unsure of the syntax. The map[string][]byte data type is giving me trouble, because I think that the e

How to mock only one typescript class from a module, but leave other classes/functions as is, using the jest framework

I have a typescript module with a function that I'm trying to test with jest. The function I'm trying to test uses a typescript class that's defined in the same

I am trying to set a cookie in supertest but it does not work

I am trying to set a cookie session to a post request in supertest but I cannot. This is my test code: const app = express(); app.set("trust proxy", true); app

Encoding issues using tycho surefire plugin

I've been turning my head around with this issue and cannot find an explanation for what is happening here. I'm using tycho surefire plugin to build a set of ec

Error: Hilt Fragments must be attached to an @AndroidEntryPoint Activity

Fragment is not loading in Unit Test. Code: @RunWith(AndroidJUnit4::class) class DataFeature { @Test fun testEventFragment() { val fragmen

Why Jest tests are SOMETIMES failing on CircleCI?

I have Jest tests that are running against the dockerized Neo4j Database, and sometimes they fail on CircleCI. The error message for all 25+ of them is : thrown

Testing function that use useQuery @apollo/client with Jest

I am trying to unit test my function that call useQuery from @apollo/client. Here's what I have done getPixelID.ts import { useQuery } from '@apollo/client'; im

What's the point of writing unit tests with mocks, if it cannot catch changes in the source code?

I started writing unit tests recently. When I try to test the service of the Angular component, I usually mock it. Therefore, if someone deletes the line of the

DataBricks Python unit test error help needed

I have a problem with unit testing in DataBricks. I have not found any similar error message yet. Could someone please help me? Below you can find my code: impo

SpringBoot Liquibase Oracle Junit test case execution fails

I have a SpringBoot application in which i use Liquibase to generate oracle schema and tables. When i run the application, it runs fine. But when i try to run t

Using PowerMockito with ArgumentCaptor

I simply try to test the following part of my service method: if (isDeleted) { LoggingUtils.info("Deleted. ingredientUuuid: {}", ingredient.getUuid()); } I

Django rest framework: Unit testing post request gets status code 400

I'm doing some unit tests in this restaurant app, and the API request to cancel orders returns code 400 when running "manage.py test" command, but doing the sam

How to Mock QueryAsync using Dapper for unit testing an Oracle stored procedure call which returns a RefCursor

I am writing a unit test case using MOQ framework for testing an Oracle stored procedure returning a RefCursor. My project is in c# and we are using Dapper to c