85,916 questions
-1
votes
0
answers
11
views
@Test keep getting null instead of expected result
I'm testing a Spring Boot service method that performs a SELECT via a repository. The method is supposed to return a ykymd value from the database using a few fields. However, even though I use @Sql ...
0
votes
1
answer
25
views
Why Can This Not Write To Directory 'Output'?
I am attempting to write a file to an existing directory, using node, path, and fs.
How it's supposed to work:
Init mock data.
Loop through mock data.
Write mock string to existing directory 'output'
...
1
vote
2
answers
42
views
How to test Angular's output signal?
I have an output signal in my component like this:
updatedBook = output<Book>();
...
updateBook(changedBook: Book){
this.updatedBook.emit(changedBook);
}
In the template I have a binding ...
1
vote
1
answer
19
views
Flutter test fails with assertion '!node.isInvisible || children.isEmpty' in object.dart during scheduler callback
I was following the code from : Google Codelabs Example I'm running a widget test in my Flutter app using: flutter run test/home_test.dart and I get this error during the test execution.
Error: ════...
0
votes
0
answers
11
views
How to use FFF + Unity to fake a static function defined in the same file as the function under test?
I'd like to explain a situation in which I want to test a function using Unity and FFF. I understand Unity and FFF somewhat well. I'm still not familiar with all their capabilities, and now I find ...
2
votes
1
answer
43
views
How to unit test MapHttpAttributeRoutes() for ASP.NET
How to unit test the following method?
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
}
}
The ...
0
votes
2
answers
59
views
How to consistently stringify maps when key iteration is not ordered?
I am building a heterogeneous map for an interpreted programming language in Go. As part of the language, I want to be able to stringify any value for printing.
I have the following code:
// ObjKind ...
1
vote
1
answer
43
views
+50
Angular Karma, what is causing "flush failed after reaching the limit of 20 tasks. Does your code use a polling timeout?"
I'm testing a component that internally uses several services and sub-components.
This test fails with "flush failed after reaching the limit of 20 tasks. Does your code use a polling timeout?&...
0
votes
1
answer
13
views
Writing unit-tests for Rule of Maven Enforce Plugin
I am writing custom rule for Maven Enforcer plugin.
Inside of that rule I need to collect dependencies. So, I am working with RepositorySystem:
@Named("myRule")
public class MyRule extends ...
0
votes
0
answers
29
views
Don't know which branch is missing in jacoco report
I am writing Unit test for usecase in kotlin but don't know how to cover missing branch.
// ConnectFTPUseCaseImpl
// ConnectFTPUseCase
interface ConnectFTPUseCase {
suspend fun connect(): Result&...
0
votes
1
answer
73
views
Unable to call Mock method in golang using testify/mock
I am using stretchr testify for mocks. In actual go code the function MyData() however calls another function MySub() with same struct type. And I want to mock the MySUb() only. So, when I call the ...
0
votes
0
answers
55
views
How to "Don't Mock Things You Dont Own" with JDBC
This is a question about "testing patterns". How to "Don't Mock Things You Dont Own" with JDBC?
I tried to Proof Of Concept a JDBC Adapter in the below link, and after trying a ...
1
vote
2
answers
56
views
Angular unit tests failed because of special character (UTF8 issue ?)
I'm using angular 19 since couple of months and i test my app with karma in a bash temrinal.
I don't know why and when but since some days, my unit tests failed on special characters not recognized by ...
1
vote
1
answer
120
views
Java Spring - unit test config class
I have a Java Spring application with a RedisService for interacting with a Redis database. The RedisService constructor takes a JedisPooled object as the constructor dependency for using the Redis ...
1
vote
1
answer
26
views
How to generate an executable output file for "zig build test"
It seems that "zig build test" will run the unit tests automatically, but I want to generate an executable file which calls all the unit test functions, then I would like to load the ...
-2
votes
1
answer
293
views
write and run unit tests after concurrent execution by multiple threads without writing all the concurrent calls and pool creation myself? [closed]
I have a class method that updates the state of the object in a thread-safe manner.
I want to add some basic unit testing to show that upon concurrent execution certain invariants still hold in order ...
-1
votes
1
answer
35
views
How to debug line breaks in returned string
I want to print out a guide board for a TUI card game I'm working at the moment. I could write the code for it but my test fails even though got and want look exactly the same in the test result. As a ...
0
votes
0
answers
46
views
How to diagnose root cause of Angular error NG05104, "Root element was not found during bootstrap" in jest test suite?
I am working on a large Angular project, currently on Angular 17. It uses jest for unit tests, of which there are currently few. I am working to fix that. I find that as the test suites get big and ...
0
votes
0
answers
60
views
How to test useSuspenseQuery hook
Recently I read about new hook useSuspenseQuery provided in @tanstack/react-query v5.
Previously I have used useQuery and have written unit tests on it.
I am trying to write unit tests on ...
0
votes
0
answers
22
views
Can't link Azure Test Plan with Automated Unit Tests
Introduction to Problem
Basically, in Azure DevOps, I have created a test plan. Within the test plan I have a test suite with two test cases. In Azure repo, I have an entire project with two unit ...
-1
votes
0
answers
19
views
TypeError: User.findOne.mockResolvedValue is not a function when using jest.mock() with Mongoose model in Jest tests
I'm encountering the error TypeError: User.findOne.mockResolvedValue is not a function while trying to mock the Mongoose findOne method in my Jest tests. The issue occurs even though I have properly ...
0
votes
1
answer
20
views
Trouble Adding Mocks and Patches to a Test on a Route
I have a Flask API with a route like:
from flask import current_app
from utils.linked_list_handler import get_ll
import json
@detail_bp.route("/get_base_details", methods=["GET"])
...
1
vote
2
answers
139
views
How do I unittest an HTML page that contains an embedded dynamic image?
I've got an dynamic HTML page that contains a QR code that is generated dynamically and embedded using <img src=data:image/png:....>. I had been testing the page by generating it with specific ...
5
votes
1
answer
91
views
Angular Material MatSort's sort function not updating DOM in unit test
I’m testing an Angular GridComponent that uses MatTable with MatSort to sort data by the age column in descending order. The test expects "John" (age 30) in the first row and "Jane"...
0
votes
1
answer
28
views
Dbt unit test without real table in warehouse
I am researching about Dbt unit testing, and recently read a NOTE in Dbt document
The direct parents of the model that you’re unit testing (in this example, stg_customers and top_level_email_domains) ...
-3
votes
0
answers
47
views
FlaUI WPF UI Automation test not detecting text change after button click
I have a simple WPF app that changes a TextBlock's text when a button is clicked. My FlaUI-based xUnit test can find the elements and click the button, but it doesn't detect the text change even after ...
1
vote
4
answers
122
views
Unit test fails when running all tests, but not when run as a single test
One unit test keeps failing when I run all unit tests, but doesn't fail when running it as a single test. I've marked it with a comment below. When firing the RulesEngine via Session.Fire() there is ...
1
vote
1
answer
21
views
Testing Helm hook with Helm unittest
YAML to be tested
metadata:
annotations:
"helm.sh/hook": pre-upgrade
Unittest
- it: annotations validation
asserts:
- equal:
path: metadata.annotations."helm....
0
votes
1
answer
36
views
Using Microsoft.Testing.Platform in C#, is there an easy way to get the error output in an automated build pipeline, for example a GitHub workflow?
By default, xUnit writes a summary of failed tests to the console. This makes it easy to get an overview of what failed. Many other test frameworks do something similar, I believe.
In contrast, ...
-1
votes
1
answer
36
views
FluentAssertions - Should().BeEquivalentTo() reports different length on equal strings
In a unit test, I am comparing JSON output from a serialization operation.
It's very simple, I just compare raw strings with each other. Now, the strings do visually match, but my testing framework, ...
0
votes
0
answers
21
views
How to mock History API using Sinon, Mocha and JSDOM?
I've writing a simple single-page application from scratch, and it has a simple router class. It works fine, and now is time to create unit tests for router. For testing, I use Mocha + Chai + JSDOM.
...
0
votes
1
answer
45
views
Is it possible to mock out a character device file in userspace?
I have a user space application that opens a Linux device file handle (e.g., /dev/foobar) and then sends ioctls to it.
I need to replicate a specific series of answers from the device delivered back ...
-1
votes
1
answer
41
views
vi.spyOn(reactRedux, 'useDispatch') is not working / "TypeError: Cannot redefine property: useDispatch"
I don't seem to find a solution for the below code / test to work (I went through a lot of articles and stackOverflow...). Various solutions provided by chatGPT are useless as well. I also see people ...
1
vote
1
answer
60
views
Mock asyncio.sleep to be faster in unittest
I want to mock asyncio.sleep to shorten the delay, e.g. by a factor of 10, to speed up my tests while also trying to surface any possible race conditions or other bugs as a crude sanity check. However ...
0
votes
0
answers
36
views
ZyBooks 5.18.1 Unit test troubles
I'm attempting to do the ZyBooks Swapping Values Lab, and I've hit a bit of a snag. Here's the code I have as of now.
''' Define your function here. '''
def swap_values(user_val1, user_val2):
...
0
votes
1
answer
67
views
How to mock functions in streamlit unit tests?
I have a streamlit app, for which I'd like to create unit tests. I am unable to mock objects though.
I have a foo.py with the following content:
import streamlit as st
def dialog_func():
result = ...
1
vote
1
answer
46
views
How to mock service responses in Angular unit test
I have an ngOnInit() function in a component that checks session storage via a StorageService to see if a user is logged in, and what their account type is. It will then assign an isAdmin bool to true ...
0
votes
2
answers
37
views
Trying to add stubs in a loop and getting a Mockito exception: Incorrect use of API detected here
I'm using Mockito to creating unit tests for Java however I encountered a weird issue
Say I have an ObjectUnderTest with a mainMethod, and a dependency Dependency mocked, with a method mockedMethod:
...
0
votes
0
answers
32
views
How to run unit test parallel in fastlane iOS
Is there any useful plugin to run parallel unit test in fastlane for ios?
lets say like i have 10 schemes, currently its running in loop but it is taking too much of time. so i wanted to run parallel ...
0
votes
1
answer
63
views
What is the correct implementation for unit testing a WPF application using dependency injection?
I have a singleton model class (Project) shared application-wide through dependency injection.
Works great in the application.
I have another model class (Analysis) that accesses this singleton that I ...
0
votes
0
answers
21
views
Angular will not run a single test file
I am trying to run a single spec.ts file, but Angular keeps picking up many other files. Here is what I have tried:
ng test --include src\app\global.service.spec.ts
ng test --main src\app\global....
0
votes
0
answers
19
views
Jest Unit Test Throwing a Timeout Error MsSql.Connect
Test file:
jest.mock("mssql", () => ({
connect: jest.fn((config, callback) => {
if (config === "validConfig") {
callback(null);
} else {
...
-4
votes
0
answers
74
views
How do I properly mock a function?
I developed a AWS Lambda function in Go. Now I'm trying to unit test it.
In my main.go I have this variable:
var (
core *Core
)
Core is a struct that holds SecretIDs, a httpClient and so on.
I ...
0
votes
0
answers
48
views
How to make sure that resources are not shared in dotnet unit tests and the tests run sequentially? [duplicate]
using System.Net;
using System.Text.Json;
using Microsoft.Extensions.Logging;
using Moq;
using Moq.Protected;
using NUnit.Framework;
namespace pg_sdk_dotnet.tests;
public class GlobalSetup{
...
0
votes
1
answer
61
views
Mocking a C# method with an out parameter to return different values with Moq [duplicate]
I have a C# method with an out parameter:
public bool TryGetNext(out Bestellung? bestellung);
When setting up a mock for this method using Moq, how do I:
Correctly handle the out parameter in the ...
1
vote
1
answer
64
views
Showing differences between non-matching strings using assertJ
I'm currently working on a unit test for a kotlin function that will generate a csv file from some model data. I'm running into some strange test failures and the default output from assertJ isn't ...
1
vote
3
answers
159
views
How to match any parameters in Setup() without using It.IsAny<T>?
Here is my code, as you can see there are many It.IsAny<> which look ugly.
_mockTimeSpanModel
.Setup(
x => x.CaptureTargetScreen(
It.IsAny<string>(),
...
0
votes
1
answer
90
views
How to write a conceptually correct unit test for API method with Linq?
I'm learning how to write unit tests, please don't judge heavily. I have an API method below, written in C# for .NET 8.0, which I want to test. I use XUnit, Entity Framework Core 8, SQL Server 2019. ...
0
votes
2
answers
42
views
Can setup methods run in parallel for NonParallelizable tests?
I have a test method with a NonParallelizable attribute. The question is:
Can it be, that TestSetup() method runs in parallel to the running TestMeth() of previous test case and only TestMeth() ...
0
votes
0
answers
34
views
Change detection not work in Angular unit test
My test does not pass. If I remove the requiredPermission structural directive, the test pass.
report-button implementation is just a boolean input signal that check a button.
When I removed the ...