85,749
questions
-1
votes
0
answers
18
views
not able to render redux store data in testing
Iam trying to test my movieList component using enzyme by providing data through store In my movieList component There are several conditions like if data is loading render loading state till it ...
0
votes
0
answers
21
views
How can I mock up the express-validator withDefaults function using jest?
I am trying to unit test my validation segment which uses express-validator.
This is the start of the segment:
const errorMsgs = require('../lib/error-messages');
const validationResults = ...
-1
votes
0
answers
18
views
Neo4J Cypher condition - how to unit test it?
In the application I am working there is a repository defined as:
@Repository
public inteface EntityRepository extends Neo4jRepository<Entity, String>, CypherdslConditionExecutor<Entity> {}...
0
votes
0
answers
11
views
Actual value of OUT variable is *error* in Tessy
My colleague has a simple Tessy test. There is only a call of a stub in it. After running the test the actual values of the OUT variables are error. Unfortunately I was not able to help him:(
Does any ...
4
votes
1
answer
34
views
How to have decorated function in a Python doctest?
How can I include a decorated function inside a Python doctest?
def decorator(func):
def wrapper() -> None:
func()
return wrapper
def foo() -> None:
"""
...
0
votes
0
answers
24
views
How to cover with unit test a settimeout in a event listener in angular method?
Using jasmine and karma, I can pass the unit test using fake async and using a real event, but the coverage is not correct, the settimeout call back is ignored.
@Component({
selector: 'slider',
...
3
votes
2
answers
102
views
Compare two boolean arrays considering a tolerance
I have two boolean arrays, first and second that should be mostly equal (up to a tolerance). I would like to compare them in a way that is forgiving if a few elements are different.
Something like np....
0
votes
0
answers
22
views
the test coroutine is not completing with paging3 viewmodal unit test
I am getting following error, while testing view modal with paging 3,
Unit Test Link: https://github.com/TheReprator/ToDo/blob/main/appModules/searchToDo/src/test/kotlin/dev/uimodule/searchTodo/...
0
votes
2
answers
30
views
Run ABAP Unit Tests Programmatically
How can we run ABAP Unit tests programmatically from say, a standard ABAP report?
We want the tests to run on a schedule and to be able to display the results pass/fail in a normal ABAP ALV list.
Note:...
0
votes
1
answer
23
views
C# unit test got type conversion error on mocked objects, so how to convert the Moq.Mock type to the wanted type?
We are trying to set up a unit test for a C# controller class, named FunctionController, so the unit test is the class FunctionControllerTests.
To build an instance of the controller under test, we ...
0
votes
1
answer
13
views
Using RunOaktonCommands in combination with a test using a WebApplicationFactory results in a ObjectDisposedException
I have the following program:
public sealed class Program
{
public static async Task Main(params string[] args)
{
try
{
var builder = WebApplication.CreateBuilder(...
1
vote
1
answer
58
views
Unit Testing Angular: Cannot read properties of undefined (reading 'ɵcmp')
I'm trying to develop a test for a component of an Angular (v18) application.
The component is standalone and the file spec file is the autogenerated one, I added only the services that the component ...
-3
votes
0
answers
59
views
Which coding techniques or principles emphasize on testing simple classes [closed]
Which coding techniques and/or principles says or leans toward that unit testing simple classes like a simple enum class is worthwhile or a good idea.
Take this example from:
An answer of: How to test ...
0
votes
0
answers
10
views
I can't run my simple application with the About form in the Main Form's About Menu
I can't run my simple application with the About form in the About Menu. After creating the About Form with the Main unit also created, when I run it, only the About dialog box appears.
I prepared the ...
-2
votes
0
answers
19
views
Make changes to the virtual envirnoment rather than the code for running unit test caes [closed]
I have the codebase of one of the features of my company.I have made some changes to the local and will deploy it soon.Before deploying it,I want to test the unit test cases and check whether they are ...
0
votes
1
answer
13
views
Is there a replacement for assumeThat in JUnit 5?
I am migrating code from JUnit 4 to JUnit 5. Is there any replacement for the method Assume.assumeThat?
0
votes
0
answers
34
views
error testing custom backstage plugins with jest
I am a new tester testing backstage components and I am having problems with jest when processing them because of the following issues:
I'm testing with typescript and I'm trying to test external ...
-1
votes
1
answer
35
views
Mockito mock not invoked
I have some java base class that has inside 1 method:
public class SB {
@SneakyThrows
public Document downloadHtml(String url) {
return Jsoup.connect(url)
.userAgent(&...
0
votes
0
answers
23
views
ESP-IDF: Unit tests not detected for source files in main folder (not in components)
Similar to this question I am having problems with unit testing in ESP-IDF; it does not find my unit tests.
The only difference with the other question is, I don't have components I want to test, but ...
0
votes
1
answer
12
views
Mockoon | Error while serving the content
I am using mockoon to mock an api with endpoint localhost:3004/api/v1/users1?filterBy=lastName&value=Brown. Basically I am trying to implement mock api which supports filtering. I am using a data ...
0
votes
1
answer
40
views
Symfony X-CSRF-TOKEN failed to be send
In this code:
<?php
namespace App\Tests;
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Contracts\HttpClient\ResponseInterface;
class ...
0
votes
1
answer
16
views
Jest with Firestore: ReferenceError: Cannot access 'object' before initialization
I'm having a problem with my jest test to mock my Firebase functions
roleService.unit.test
import { RoleService } from "../../services/RoleService";
import { CustomError } from "../../...
0
votes
0
answers
22
views
Angular Deferable Views tests just won't work
So I've been messing around with adding Deferable Views to my Angular app. However, doing so breaks the unit tests for everything that's behind a @defer. What happens is that no code works if it's ...
0
votes
0
answers
12
views
Is there a way to ignore inherited tests with vstest.console.exe?
ABC.Item1.Tests & ABC.Item2.Tests references ABC.Common.Tests.
When running vstest.console.exe ABC.Item1.Tests it runs the tests from itself & ABC.Common.Tests.
This is the same for ABC.Item2....
1
vote
2
answers
53
views
How to cover the catch block in a function with optional chaining using Jest in react?
I'm working on a React project where I have a function that uses optional chaining and a try-catch block to assign a navigate function. I'm trying to write a Jest test to cover the catch block, but I'...
0
votes
1
answer
18
views
Jest mock of a singleton function
I have a singleton class created in a module consumed within a class of an app, I am attempting to change the mock implementations return value of the singletons contained function, in the example ...
0
votes
1
answer
45
views
How should I go about importing one module from another module, where the first module itself is importing a different module?
I have 3 relevant files here, in this directory set up:
src/operator_precedence_high_roller_bot/
parsing/
command_parser.py
high_roller.py
tests/test_high_roller/
...
1
vote
0
answers
27
views
Mockito: "Wanted but not invoked" error when verifying interactions with a mock in JUnit 5 test
I am writing a unit test for a class that has two dependencies of the same type, ExternalISBNDataService, in the StockManager class.
I'm trying to test that my StockManager correctly uses the ...
0
votes
1
answer
29
views
Laravel Pest. Customised folder structure. A single argument for Units and Features
I am trying to use Pest with a folder structure under single argument. I find this more readable.
Here an example of what I want to achieve:
tests/App/
├── Feature/
└── Unit/
tests/Auth/
...
0
votes
1
answer
27
views
Mocking a method with a callback function and incrementing a value [duplicate]
I'm attempting to mock incrementing a value every time a method is called however that's not appearing to work and so I'm wondering what am I doing incorrect?
var value = 0;
messageClient
.Setup(...
2
votes
0
answers
63
views
Unit Testing in TCL
In tcl, I have a library that I want to unit test, so every proc in the library should be tested separately. So when I have a proc proc foo that itself call another library proc proc bar (among doing ...
0
votes
0
answers
17
views
Can I use CppUTest with QT Creator's libraries?
I want to use CppUTest in my project which I developed in QT Creator. but there are some problems like:
I can't test signal and slot because of meta-object compiler (moc) file.
Some functions (exp: ...
0
votes
0
answers
40
views
Jest reporting lines are uncovered when they actually are covered
I have a file reporting as only 48% covered, but when I looked at the report its very confusing because it seems like those lines are covered by tests. Example:
Settings.js
class Settings {
general ...
0
votes
0
answers
22
views
shunit2 gives 'command not found' error while executing
I have a shell script to which I am trying to write the unit test code by mocking the data.
Intention of the actual logic:
script automates the extraction of file changes between two Git commits and ...
0
votes
0
answers
25
views
Puppeteer- why did my dropdown locator not working?
I have this dropdown on my page
<select class="form-select">
<option disabled="" value="none">Choose Option</option>
<option value="value-1&...
-1
votes
0
answers
78
views
How can I mock I/O operations in Rust?
I have the following Rust code that I want to unit test. The code finds files that match a glob, and then processes the files line by line, sending the files to the analysis endpoint.
let paths = ...
1
vote
0
answers
19
views
Python Unit Tests Stalled in Docker Container when Creating multiprocessing.Manager()
I am running my unit tests in a Docker container, but the below function stalls out when creating the multiprocessing.Manager(). What can I add to my code to get this work? Do I need to make changes ...
-1
votes
0
answers
36
views
Plugin for OpenCppCoverage to do Branch Coverage [closed]
I am asking your help today in order to know if there is any plugin for OpenCppCoverage in order to have also the branch coverage, i saw this post but as it's an old post, i don't know if there is any ...
-1
votes
0
answers
30
views
Testing Data Transfer Objects (DTOs)
I'm writing unit tests for a NestJS app using Jest and am wondering whether it's necessary or beneficial to create unit tests for DTOs (Data Transfer Objects). Are there any pros and cons to testing ...
0
votes
1
answer
40
views
+350
unit test that code in after_this_request + call_on_close was executed after request
The example code below is similar to this answer, it runs a function after a Flask response has been returned. This works just fine.
My question is how can I unit test via the Flask.test_client that ...
-1
votes
1
answer
100
views
tSQLt - How to fake/mock sequences
I'm creating various unit tests for our database using the tSQLt framework. Many of our stored procedures insert records into various tables. These procedures directly call our sequences to create IDs ...
-1
votes
0
answers
26
views
How to add validation messages from API responses when testing in Mocha, Java
How do I add the api response in the below tests. So I am trying to validate 4 columns. I got the test to pass and it validates that we should get a 422 Reponses as those columns are missing that is ...
-2
votes
1
answer
41
views
How to mock the behavior of FileReader while doing Unit testing in Junit5
I have a service class which tries to read the content of CSV file and saves it to Database.
I am trying to mock this behavior in Junit 5 and whatever I pass I am just getting error message as ...
1
vote
2
answers
30
views
How to test observable that emits multiple times on subscription in jasmine angular framework
I am having a service product.service.ts
class ProductService {
public product$: Observable<string> = from(['prod1','prod2','prod3','prod4']);
<other methods goes here...>
}
I want to ...
2
votes
1
answer
60
views
How to use @TempDir with JUnit 5 @ParameterizedTest to create a separate temporary directory for each test?
I am using JUnit 5's @ParameterizedTest annotation to run tests with different inputs, and I want to generate a separate temporary directory for each test. Here's how my code looks:
class MyTestClass {...
0
votes
0
answers
16
views
Unit test API controller using fluentValidation
If I have an API Controller that gets am model of type "product" which is checked for valid name via fluentValidation ( nameNotNull, nameNotEmpty) how do I write a unit test for the ...
0
votes
0
answers
16
views
Return row from csv file based on user input and test function [duplicate]
I have a csv file with a list of cities and the price of a night in the hotel based on tier. I want to test the function but understand I shouldn't have input within a function that's not main. This ...
0
votes
0
answers
15
views
Why Blazor bUnit test is asking for services registration
I have a Blazor project that uses several services registered in program.cs.
If I add any component to the project and then prepare tests for it in the Test project, it still requires that I register ...
0
votes
1
answer
42
views
Got error "Function called outside component initialization" when testing Svelte component with Vitest
I want to test the following Svelte component with Vitest:
<script context="module">
import {push} from 'svelte-spa-router'
import {onDestroy} from 'svelte'
let time = ...
0
votes
1
answer
23
views
Django Mock database not working properly
I was coding a unit test method for a post method, but for some reason, it keeps modifying the actual database instead of the mock database.
This is my test method:
def test_post_contest(self):
...