6,157 questions
Best practices
0
votes
0
replies
49
views
Testing in MVVM architecture. What to test and how to approach TDD?
I’m currently working on a personal Android project using Kotlin and Android Studio, following a basic MVVM architecture:
─main
│ ├───java
│ │ └───com
│ │ └───example
│ │ └───...
1
vote
1
answer
117
views
How to test the calling sequence of methods of a class?
Sometimes when I develop by TDD (Test Driven Development) I need to test the calling order of some class methods. In general I write Python code so I'll show the last test case that I have just ...
0
votes
2
answers
71
views
Write tests that check the order in which actions are done
I'm encountering a recurring challenge when using TDD to develop code that must perform actions in a specific order. Usually I'm able to write tests such that it is only possible to create a correct ...
0
votes
1
answer
40
views
Gateways design in a react native app with TDD approch and clean architecture principles
I'm currently developing a mobile app for booking overnight accommodations in React Native. I'm currently developing the "book accommodation" functionality and I'm running into a design ...
3
votes
2
answers
9k
views
How can I run a uv pytest tool with proper dependencies and module paths?
Directory Structure
project-root/
├── src/
│ ├── file1.py
│ ├── file2.py
└── tests/
│ ├── test_file1.py
│ ├── test_file2.py
├── requirements.txt
├── pyproject.toml
So basically, under the project ...
1
vote
2
answers
147
views
Should I write a test for each required attribute in a Rails model or is one enough? [closed]
I'm working on a Ruby on Rails project and practicing Test-Driven Development (TDD) using Minitest.
For user authentication (using Devise), I wrote a test to check that a user cannot sign up without ...
0
votes
1
answer
153
views
Pytests using SQLAlchemy + Factory Boy are not persisting data on database
So i'm building a FastAPI application whose tests are written in Pytest. Because i have some large models, it is unpracticable for me to define different data manually each time i have to query or do ...
1
vote
2
answers
158
views
How should I compare the values of non-nullable and nullable types using ShouldBe in Shouldly?
In the following code, o[0].AccountEnabled has type bool while graphUsers[0].AccountEnabled has type bool?.
Without the explicit cast to bool?, I get the following error:
'bool' does not contain a ...
1
vote
1
answer
578
views
How to mock composable with vitest?
I'm learning TDD in simple Nuxt.js project. This project is frontend of Laravel API. And what this project does is to implement all Laravel Fortify options. So I'm using external package called nuxt-...
-1
votes
3
answers
204
views
My class doesn't generate a Fibonacci sequence properly
I'm trying to make a class that generates a Fibonacci sequence. My two modules are below, the fibonacci.py module and the test_fibonacci.py module. The first two tests pass but the third one seems to ...
0
votes
0
answers
58
views
How can I use the same test_helper function in integration tests and unit tests in rust?
So I have an integration test /tests/my_test.rs and a unit test in /src/some_module/function.rs. If I create a test helper in
/tests/test_helper.rs
pub struct TestHelper {
}
impl TestHelper {
fn ...
0
votes
2
answers
126
views
How to test debouncing logic
I'm trying to use TDD to build a search view model that debounces before searching. Until recently I would have created a mock debouncer, injected it into my view model and used that to control the ...
0
votes
1
answer
46
views
Why is Karate scenario and scenario outline generating parantheses before the name?
Am using a simple Karate runner to run my features. But the karate html output is generating my scenario thus. Its adding the [1:1:22] as prefix to the Card is not used scenario name. How can i remove ...
2
votes
1
answer
297
views
Angular testing: Error: NG0304: 'mat-form-field' is not a known element (used in the 'SignInComponent' component template)
Im trying to do a small app with TDD.
When i run npm test following error occurs:
Error: NG0304: 'mat-form-field' is not a known element (used in the 'SignInComponent' component template):
If 'mat-...
1
vote
2
answers
89
views
TDD process when you know the implementation of a new feature overlaps a previous one [closed]
I just solved this puzzle using TDD:
https://adventofcode.com/2015/day/6
I started with turnOn function and implemented like this(F#):
let turnOn (startx, starty) (endx, endy) (grid: bool[,]) =
...
1
vote
0
answers
57
views
Best approach for doing Test-Driven Development with Kernel Mode Windows driver
I have an existing kernel-mode device driver that implements a installable file system (IFS) for Windows. As there are several parts of the driver that should not require operating inside the kernel ...
0
votes
1
answer
69
views
How to TDD and fully test templated code that takes variadic number of arguments and which has specializations without code duplication in the tests?
Let's say I want to write a function that returns sum of passed positive numbers. Just returns 0 if I don't pass any.
And I decide that I want to pass arguments just as a list of arguments and as a ...
1
vote
2
answers
98
views
TDD, Unit Test and mocks injection: What about the Single Responsability principle?
I'm writing a Unit Test for a Class (CustomHttpClient) that internally uses a library (java.net.http.HttpClient) to make an external HTTP call.
Being it a Unit Test, I would mock the internal ...
-1
votes
1
answer
557
views
How to set an EXPECT_CALL to a mock object that is just created?
Here is my situation with testing. There is a note in googletest that EXPECT_CALL’s must be set first before the calls on mock methods (https://google.github.io/googletest/gmock_for_dummies.html#...
1
vote
1
answer
63
views
Maintaining test isolation and not testing implementation with API wrappers
I'm new to Test Driven Development and I've been thinking about how to test some API wrappers which perform modifications on the received data so it complies with my own custom format. I ran into an ...
1
vote
2
answers
463
views
Can I write one expectation in RSpec which demands a method is called only once with specific arguments?
I'm just finishing my first year writing production code in Rails, and I'm not really stuck here, but the non-rubyness of what I'm experiencing is weird, and I wanted to see if anyone had this problem....
2
votes
1
answer
208
views
Mock EncryptAsync method and return EncryptResult from Azure.Security.KeyVault.Keys.Cryptography
I am trying to mock the functionality of the EncryptAsync method in Azure.Security.KeyVault.Keys.Cryptography.CryptographyClient.
This is the method I am trying to cover in my unit test.
public ...
1
vote
1
answer
96
views
Encapsulation in Typescript for export functions
I am new to Typescript, but with my JAVA Knowledge, I believe exporting functions breaks Encapsulation principles.
for example:
hello.ts
** Below method will be called from outside ***
export const ...
0
votes
1
answer
34
views
TDD when DDD with lots of dependency in information model
The system is designed with entities for each of the business elements. Each entity is represented as a class with methods for its behavior and property for its data. We map the entity to the database ...
0
votes
3
answers
673
views
Testing SwiftData models in test target, "failed to find a currently active container"
I'm building out a SwiftData model in the preliminary stages of app development. I'm using test-driven development (tdd) to iterate on the model and iron out kinks prior to integrating the model into ...
1
vote
2
answers
176
views
How do unit tests work in test-driven development?
I've been thinking a lot about unit tests today and I got a bit puzzled as to how exactly unit tests are created during the test-driven development (TDD) process. (To be clear, a unit test for me is ...
0
votes
1
answer
61
views
Is there a boilerplate template for a TDD approach in Django-Python
I’m working on a side a project while trying to discipline myself to get accustomed to the TDD approach in Django.
I'm not sure why I’m running into this failed test
(venv) osahenru@osahenru ~/D/q-4&...
0
votes
0
answers
149
views
How to mock web3 method call
How would one mock this call to a ethereum smart contract using the web3 js library.
export const getERC20Balance = async (
web3Client: Web3,
tokenAddress: string,
walletAddress: string
) => {...
3
votes
1
answer
494
views
@DataJpaTest & @SpringBootTest querying src/main/resources database instead of src/test/resources database
Im trying to thoroughly understand Spring Boot, especially testing.
I want all tests to run against the database in application.properties inside src/test/resources regardless of the active profile. ...
3
votes
1
answer
273
views
How can I return self from a method mocked using mockall?
Given the following test context which makes use of the mockall library, how can I satisfactorily return a reference to cmd that will allow me to make assertions about subsequently chained method ...
0
votes
1
answer
71
views
Should I add the nupkg dependencies of the Assembly of the SUT to the Test Project as well?
I'm relatively new to writing unit tests. I ran into this scenario while writing unit test cases in .NET 8,for azure functions.
Project 1 - ABC.Functions
Project 2 - ABC.Functions.Test
I have added ...
2
votes
2
answers
433
views
Testing DAO Methods in Java: Fake Implementations vs. In-Memory Databases
I’m currently working on a Java project using Java 17, Dropwizard, and JUnit 5, and I’m focusing on improving my unit tests and adopting Test-Driven Development (TDD) practices. My application ...
0
votes
0
answers
91
views
Unable to consume message - MassTransit with ActiveMQ Artemis
public class MessagePublisher : BackgroundService
{
private readonly ILogger<MessagePublisher> _logger;
private readonly IBusControl _busControl;
private readonly IMessageIcd ...
0
votes
0
answers
67
views
I'm having this error in my app ruby on rails
StandardError
Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Active Record release the migration was written for:
class AddAttachmentImageToPosts < ...
0
votes
1
answer
1k
views
Setting up/using a session in a phpunit test
I have a simple class that wraps around serializing/deserializing an array of objects and adding them to the session and I want to test it.
The errors I've gotten are
the there is no session ...
1
vote
1
answer
1k
views
Unit test framework for .net maui hybrid blazor app with .net 8 and target Android and Windows
I just wondered which unit test framework to use in a .NET MAUI Blazor Hybrid app with multiple targets like Android and Windows.
I already tried nUnit and xUnit, but it is not working out of the box. ...
2
votes
0
answers
314
views
CMock's behaviour for IgnoreAndReturn
I am currently trying to understand the intricacies of CMock's IgnoreAndReturn feature.
This is the function under test
void USBDriver_Exec(void)
{
uint8_t Val;
// When ...
0
votes
0
answers
427
views
Testing Cerner CCL Query Data with Oracle's Unit Testing Framework
I've been looking for a unit-testing framework for Cerner CCL (now with Oracle), and it looks like one does exist here:
https://github.com/cerner/cclunit-framework/blob/main/doc/CCLUNITTESTS.md
For ...
1
vote
3
answers
234
views
Why should I use triangulation instead of just randomized values in my tests?
Since I started learning and using TDD I was wondering something about the "triangulation technique": why bother writing multiple tests when we could write one that use randomized values?
...
1
vote
0
answers
108
views
Is Test Driven Development possible in jetpack compose?
Is TDD (Test Driven Development) impossible since testing compose requires that the UI to be tested already exists?
Or are you creating a FakeScreen and testing it?
0
votes
1
answer
144
views
Rails tests are passing but server refuses to start on production due to syntax error [closed]
This is one weird issue I am facing. All the test cases are passing on the CI/CD but there's a syntax error in one of the files.
And when this changes goes to production the server refuses to start.
...
0
votes
0
answers
37
views
The non-nullable local variable 'mockLoginRespository' must be assigned before it can be used
I am trying to develop my app using Clean TDD (Test Driven Development) Architecture. For the login feature , I am writing the test case as follows:
import 'package:dartz/dartz.dart';
import 'package:...
1
vote
2
answers
201
views
Unittest in according to TDD on Palindrome
I'm student at QA and now I try to write a palindrome code in Python based on TDD and unittest.
I tried to write the code and it is functional but it doesn't work in according to assertTrue, also I ...
0
votes
2
answers
198
views
Is there a simple way to invert a test or test group?
Assume you have written a failing test to exploit a bug. You want to push this to upstream and then create a story that is about fixing the code so that the test passes. However, this is prevented by ...
1
vote
0
answers
60
views
How would you develop a function for API response parsing using TDD?
I just read "Test Driven Development: By Example" by Kent Beck, and I am trying to apply it on my current project.
Given an API response I need to extract information from it. API response ...
0
votes
1
answer
359
views
Ignore the rest of a function after asserting that a function is called in python
In Python, we want to assert that a function is called when calling another function. However, we want to ignore the execution after calling the required function. This necessity appears when we don't ...
0
votes
2
answers
115
views
How to verify that a specific method was called with this parameter or another parameter using mockito?
How to verify that my sendMessage method is called with Msg.SAVE or with Msg.UPDATE using mockito's verify method.
@Service
public class CustomerService {
private final CustomerRepository ...
-1
votes
3
answers
583
views
How to write a test case to check if numbers in an array are unique when the array is created randomly?
I'm writing a specification for a lottery function that should create an array of seven (random) numbers between 1 and 49. The numbers in the array must be unique, a result like [1, 2, 3, 4, 5, 6, 6] ...
1
vote
2
answers
100
views
What am I doing wrong in bdd / gherkin?
I'm learning about BDD, Behavior-Driven Development, and while I caught the "idea" of having examples of the system's behavior, which we can execute and through which we can develop it, I'm ...
1
vote
2
answers
155
views
How to unit test your Abstract data type without getters and setters in C?
I am currently trying to refactor some of my embedded C code and am trying to apply what James W. Grenning is recommending in his Test-Driven Development for Embedded C book. For this, I am dividing ...