Questions tagged [tdd]

Test-Driven Development (TDD) involves writing a failing automated test to specify what is to be built. The test is then made to pass by writing code which satisfies the tested condition. Finally, the code is refactored.

tdd
967 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
0 votes
1 answer
100 views

Pytest DynamoDB client.describe_continuous_backups returns error

I am trying to test if a newly created table has continuous backups enabled. I am using Python and pytest as follows: client = boto3.client('dynamodb', environ['REGION']) backup_status = client....
Sylwek's user avatar
  • 107
0 votes
1 answer
124 views

unittest - making setUp() the single source of truth for test data and its effect on parallelized testing

As far as I know, using unittest in Python is done something like this - # test.py import unittest import math from my_math import do_math class test_do(unittest.TestCase): def test_first_case(...
Anirudh Rowjee's user avatar
0 votes
0 answers
87 views

Why is my class constructor returning undefined?

I am learning Javascript classes and TDD currently and for some reason my class constructor is retuning undefined instead of a string. Have I missed something obvious? Class: class Passenger { ...
lhuf's user avatar
  • 42
0 votes
0 answers
54 views

React JS test case for componentWillMount(), testing asynchronously API call

I am trying to write a test case for the below code, export default class App extends React.Component { constructor(props) { super(props); this.state = { userProfile: {} }; } async ...
Pratik Khobragade's user avatar
0 votes
2 answers
200 views

I'm writing a test case in React related to authentication(using axios), But I am stuck because the test case is not passing

Existing code: loginUser.js: import { getUserDetails } from '../api/userDetails'; import { mapApiObjectToModel } from '../mapper/userProfileMapper'; import axios from 'axios'; export const ...
Pratik Khobragade's user avatar
0 votes
0 answers
101 views

How to write pure unittest in Django?

so my question is, how to write pure unit tests with Django? For exmaple I have this model: class Topic(models.Model): title = models.CharField(max_length=255, validators=[MinLengthValidator(5)]) ...
Piotr Kowalski's user avatar
0 votes
1 answer
81 views

JavaScript Testing spy-spies

In js testing, I can't understand the concept of Spy- Spies and the difference with stubs. spy-spies: function spyOn(Object, method) { /*... */ } // A common way of using a spy const dateSpy = spyOn(...
Atousa's user avatar
  • 147
0 votes
1 answer
156 views

Teardown logic in Kent Beck's xUnit example

I've been working through Kent Beck's Test-Driven Development By Example, more specifically the xUnit example (Chapters 18-24). I have some questions about the teardown-functionality. Originally, the ...
JKaerts's user avatar
  • 173
0 votes
1 answer
48 views

what's the correct way to organize tests for this TDD-way code?

e.g. a leetcode question has these tests or examples: Input: pattern = "abba", str = "dog cat cat dog" Output: true Example 2: Input:pattern = "abba", str = "dog ...
ERJAN's user avatar
  • 24.2k
0 votes
0 answers
90 views

Ensure cleanup code runs in an async QUnit context

I am trying to understand how to implement clean-up code after a QUnit test which involves an event being triggered asynchronously. I have seen this answer. But for one thing, try as I might, I don't ...
mike rodent's user avatar
  • 14.8k
0 votes
0 answers
73 views

Why won't jasmine run tests?

I'm just getting started learning jasmine to test JavaScript and for the life of me I can't figure out why Jasmine will run my boolean test but not my math functions test(s). Note, I am using a index....
Ken W.'s user avatar
  • 1
0 votes
0 answers
124 views

I keep getting Stack level too deep when trying to run tests for my project

I am trying to run unit tests and integration tests for my project and each time I do with the code below, it passes except three and gives these errors Randomized with seed 29775 ........FFF... ...
Didymus Orotayo's user avatar
0 votes
1 answer
64 views

TDD(iOS) SUT fails when I don't make a local variable and run some operation

I have written a test and in my test a router spy routes to the next logic of my app. using start() function. When I directly call start function on my makeSUT function test fails. However when I make ...
Muhammad Usman's user avatar
0 votes
1 answer
1k views

How to mock non-virtual methods in c++ with gtest?

Is there a clean and easy way to mock non-virtual methods in c++ with gtest ? Despite using the GoogleMock way that force you to re-declare your mocked class. This feature is essential in my point of ...
Alaenix's user avatar
  • 83
0 votes
0 answers
682 views

django test client CRUD API, unit testing

I want to write pure unit tests for my CRUD APP in django. Everyone use django tests or pytests, but I am really confused. Should I use test client to testing eg. POST method? Unit tests should be ...
Piotr Kowalski's user avatar
0 votes
0 answers
26 views

jest gives me a failed but it absolutely can't be

i am trying to run a simple test on purpose to be sure my jest setup works properly. this is my test: users.test.js import { shallowMount, createLocalVue } from '@vue/test-utils'; import VueRouter ...
Deniz's user avatar
  • 1,453
0 votes
1 answer
324 views

Is there a way to simulate connection timeout in test?

I have an application with a fail-safe routine triggered by connection timeout exception. I use mockserver for record & replay tests (which means in tests I connect to a real TCP port), but it ...
andreoss's user avatar
  • 1,720
0 votes
0 answers
954 views

Django Unit Testing A Button (Not Form)

Im writing unit tests for a Django package (Django-Notifications) and want to unit test that a notification is deleted when the 'delete' button is pressed. I know how to test forms: response = self....
horse's user avatar
  • 499
0 votes
1 answer
33 views

My function works in practice but does not pass tests rspec

Perhaps it is my lack of familiarity with rspec but i do not understand what is going on with my test. I have 2 classes one called Scrape, the other Result (creative) Scrape is a web scraping class ...
SVRourke's user avatar
0 votes
2 answers
1k views

how to test a method call once with one argument and one block in rspec

class ExternalObject attr_accessor :external_object_attribute def update_external_attribute(options = {}) self.external_object_attribute = [1,nil].sample end end class A attr_reader :...
Indyarocks's user avatar
0 votes
0 answers
447 views

Test Driven Development - Testing input parameter when using TypeScript

I'm getting started with TDD and was wondering if I need to test input parameters in a TypeScript environment? For example, I have a function which takes a string, and parses json if it's valid ...
Dusty48's user avatar
  • 568
0 votes
1 answer
200 views

No test feedback is displayed when running phpunit

When trying this command docker-compose exec app php ./vendor/bin/phpunit Or inside container like /vendor/bin/phpunit Results are like: PHPUnit 8.5.4 by Sebastian Bergmann and contributors. ..F....
Mahdi Younesi's user avatar
0 votes
0 answers
155 views

How to dry up queries in testing-libray/react library

I have a following simple test for dummy Counter component: describe("Counter", () => { it("initially displays 0", () => { render(<Counter />); expect(screen.getByText("Counter ...
luacassus's user avatar
  • 6,660
0 votes
1 answer
395 views

How to unit test Date in Swift

If I have ArticleItem struct like this: public struct ArticleItem: Equatable { public let id: UUID public let description: String? public let location: String? public let thumbnailURL:...
Tung Vu Duc's user avatar
  • 1,602
0 votes
1 answer
279 views

Laravel TDD ignored URL query params when trying to catch them in Controller with request

I would like to write a test to be sure my query parameters in URL are working fine. But whenever I do a request()->all(), I got an empty array. Here is my test part: public function ...
aspirinemaga's user avatar
  • 3,855
0 votes
1 answer
187 views

How to terminate CircleCI after running tasks?

My test passes as good as expected but the process hangs on the running status! is it a side effect of the background process? how to solve this problem? (I need to run nodeJs as a background ...
Pouya Jabbarisani's user avatar
0 votes
1 answer
100 views

How to use pytest command for code optimization

So, I am new in TDD and I recently had technical interview about task assignment that I did earlier. In interview, interviewer run some pytest command that pointed out these two lines in my code that ...
sAm's user avatar
  • 633
0 votes
0 answers
39 views

How to use ternaty operator inside expect (Jest)

I need to check if service properties does not undefined get value from action , otherway set 0. How to use ternaty operator inside expect? it('SET_CURRENT_SERVICE', () => { const action = { ...
Yerlan Yeszhanov's user avatar
0 votes
0 answers
121 views

Failing following the basic QUnit for GAS tutorial

I tried to follow rigorously this basic "QUnit for Google Apps Script" tutorial: https://blog.ohheybrian.com/2019/11/unit-testing-gas-part-1-qunit-setup/ But when I connect to the deployed web-app, I ...
Florent's user avatar
0 votes
3 answers
984 views

Unit Test ViewModel Android

I am doing TDD and I just want to verify that particular repository method is called when executing viewmodel method. class SignInViewModel{ CustomerRepository customerRepository; public void get(...
ANKUR SINGH's user avatar
0 votes
0 answers
330 views

Test react redux render return undefined component

I have this a error when I do my test: const rendered = render Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. ...
CoolLife's user avatar
  • 1,449
0 votes
1 answer
109 views

How to test react hooks with enzyme

I encountered a problem during the TDD process and the state of react hooks did not change as expected // Header.tsx import React, { useState, ChangeEvent, KeyboardEvent } from 'react'; interface ...
ender's user avatar
  • 1
0 votes
0 answers
174 views

Why xUnit tests are not turning into green?

I am using visual studio 17 version 15.9.19 on windows os. Created a xUnit Test project (.Net Core) targeting framework is .Net Core 2.2. I added all the necessary nuget packages everything looks ...
ssssage's user avatar
  • 13
0 votes
0 answers
29 views

Test Driven Laravel : Invalid Argument supplied for foreach

So i have a form with multiple fields like below <ul class="list-group list-group-flush"> @foreach ($group as $perm) <li class="list-group-item">{{$perm->name}} ...
Justin S's user avatar
  • 256
0 votes
1 answer
3k views

Laravel phpunit testing controller which returns view with data

Am trying to adapt TDD on laravel, but am getting trouble to test controller which queries a collection of records and returns view with data when I run my test it returns an error message that trying ...
D.Saidi's user avatar
  • 11
0 votes
0 answers
238 views

TDD and BDD with mockk for Android

I'm trying to get difference between for TDD and BDD when developing Android apps with Clean Architecture with UseCase and repositories. I have written a simple test with login test and using JUnit5 ...
Thracian's user avatar
  • 55.7k
0 votes
0 answers
111 views

How to use regular expression in Java to match multiple or single values in single or multiple square brackets?

I am trying to complete Roy Osherove's String Calculator as a TDD exercise and as the inputs have a pattern, i thought I would use a regex, but its something I have not used much in Java. The two ...
ArcherGilly's user avatar
0 votes
1 answer
74 views

How do I wait for the tests in a file to finish to start tests in another file using Jest?

I am using a sqlite database for the tests using Jest and before all test I truncate the tables but when I separate the tests in files it truncates the tables at the same time the tests in another ...
Vinícius de Moraes Carvalho's user avatar
0 votes
1 answer
89 views

How to test private methods with TDD approach in iOS App?

While implementing TDD for iOS app, I come across a situation where I want to perform TDD for private methods (by writing TDD func first and then adding private methods accordingly, but TDD with ...
Matrix's user avatar
  • 7,527
0 votes
0 answers
812 views

Testing Parent Component's Prop Function in React w/ Jest & Enzyme

I'm using Jest and Enzyme to test-drive my learning of React development, making a todo list app; it has a TodoList component (parent) and Todo component (child). All my tests are passing green but ...
acodeguy's user avatar
  • 125
0 votes
2 answers
822 views

What does non - testable mean in this code example?

I need to analyze a code after playing a code and see if I have full coverage. Some part of the report is shown below: game->errorCode = ERROR_NO_MEMORY; #pragma RVS ...
ml33's user avatar
  • 93
0 votes
1 answer
39 views

How to write business logic in a service as sinon in ExpressJS

I want to use sinon to write test code for the business logic of a service using ExpressJS and Mongoose. I wrote the following test code, but findOneService takes only id as an argument and returns a ...
COLEAN's user avatar
  • 675
0 votes
0 answers
94 views

Test Driven development in Yii2 not working for classes

I am very new to TDD but I am very verse with Yii2. I want to setup a basic yii2 application using TDD. I have followed a handful of tutorials online and the one that seems to work is https://code....
Nges Brian's user avatar
0 votes
0 answers
267 views

Testing That File Was Uploaded in Django

I am writing some unit-tests for an app. One of the features of this app is that it allows the user to upload videos to the server (or S3, depending on the configuration). The difficulty I am having ...
MadPhysicist's user avatar
  • 5,581
0 votes
0 answers
244 views

how to ignore entire dlls or namespaces with xunit.net?

Question: How can I configure xunit to ignore dlls, namespaces or classes from code coverage? Something like what is done with regex expressions in a runsettings file for mstest? Why I need it: ...
Klinkerhofen's user avatar
0 votes
1 answer
164 views

How to handle lots of `mockImplentationOnce` calls

I'm writing integration tests for a class that has a lot of requests. The requests are done through a HttpClient singleton. So, to avoid making real requests, I mock all calls to HttpClient. The ...
Lauro Gripa Neto's user avatar
0 votes
0 answers
96 views

Method does not throw in JUnit5 test case

I have a custom Log4j appender which is implemented as a Singleton class and expects a Layout object when the getInstance() method of the class is invoked. I wrote a JUnit5 test case to test whether ...
fnisi's user avatar
  • 1,211
0 votes
1 answer
51 views

How to mock IdentityServerDbContext to add ApplicationUser

I tried following code but it's give exceptions: var mockIdsDbContext = new Mock<IdentityServerDbContext>(); var applicationUser = new ApplicationUser() { ...
Shashikant Yadav's user avatar
0 votes
0 answers
63 views

How to write acceptance tests easily in Codeception to test a Wordpress plugin

I am learning to write a Wordpress plugin and am trying to test it using Codeception/WP-Browser. I want to write acceptance tests to test the behavior of the plugin when it is activated. The ...
Rafael Atías's user avatar
0 votes
1 answer
841 views

How to stub dependencies in unit tests when using TypeScript and Sinon

I am using TypeScript to build a Koa REST API and I'm using a dependency injection library called Awilix to make unit testing simpler. If I wasn't using TypeScript, I would write my unit tests thus: ...
jshjohnson's user avatar

1
9 10
11
12 13
20