Questions tagged [testing]

Verifying the behavior of a software system against the expected behavior of that system.

Filter by
Sorted by
Tagged with
37
votes
7answers
8k views

How do I really write tests without mocking/stubbing?

I have been using TDD when developing some of my side projects and have been loving it. The issue, however, is that stubbing classes for unit tests are a pain and makes you afraid of refactoring. I ...
0
votes
5answers
181 views

Hypothetically if every scenario were covered by an end-to-end tests, would unit tests still have any value?

Note: I'm asking about the strategy behind unit / integration / end-to-end tests, not about classifying tests as one or the other. More so in the past than present, it was expensive to write and run ...
3
votes
1answer
213 views

Clean Architecture use case testing

Use case interactors in the Clean Architecture consists of the application specific business rules. Interactors uses the Data Access Interface to fetch the required data from the data access layer. ...
1
vote
2answers
260 views

How to respond to a customer when their bug can't be reproduced

A customer has reported a bug that neither them nor us have been able to reproduce. This is the only report of this bug happening so far. We've spent a lot of time trying to replicate the issue (...
1
vote
1answer
80 views

What is better way to track mistakes in error-prone part of a feature?

That is quite specific circumstances I've come across, and I somewhat struggle to find proper way how to approach this. I'm given a class written in swift-language, which has a control property, like ...
2
votes
4answers
264 views

How do I deal with the fact that I am forced to make helper functions public for testing purposes?

I've encountered several scenarios that require me to mock certain helper methods because they call outside resources. As a result, I'm forced to convert all my helper methods from private into public....
-5
votes
1answer
39 views

Should code be refactored to be more unit testable or should a framework like PowerMock be used?

Assume there's some code that's already in production that needs some unit testing. Generally speaking, would you want to refactor this code that's already in production by adding things like adding ...
1
vote
3answers
99 views

Is it necessary to run tests in all environments?

In our project, we have DEV, STG and PRD environments that are configured to mirror each other (especially STG and PRD). We have unit tests that we run on DEV and, if they pass, are moved to STG when ...
0
votes
6answers
239 views

TDD - Make the test work quickly, committing whatever sins necessary in process

Red-Green-Refactor Green stage says, Make the test work quickly, committing whatever sins necessary in process Having an idea of writing a test & make it work quickly, does not look intuitive ...
-1
votes
1answer
65 views

Is the self-shunt pattern the same as stubbing in TDD?

I am reading the book TDD by Example and one of the patterns demonstrated was the self-shunt pattern. Basically, if I am not mistaken, if I have a test like this: test("list of users should receive ...
3
votes
3answers
183 views

Should you define an equality test solely for testing?

Assume you have a class C. C defines a public method (member function) C::m1. Calling c.m1() (c is an instance of C) can either Return after mutating the object c it was called on. Throw an ...
0
votes
5answers
155 views

How to reduce the merge-redundancy due to testing in our Git workflow?

We have are a small team of 6 people working with Scrum and Git. We are developing a quite complex webapplication with the ZK Framework. It uses Java and a MySQL database. We have adapted the "Git ...
-5
votes
1answer
64 views

Is it possible to derive a test suite to achieve 100% path coverage? [closed]

Here is an example with the function: Examining this I believe that it is possible to achieve 100% path coverage. My understanding of path coverage is that you need to design test cases such that ...
0
votes
3answers
61 views

How to control time with API testing?

I'm trying to test an API (see API testing). Some operations depend on time. Here are some examples: A post may only be edited within the first 5 minutes You may not try to login more than 10 times ...
2
votes
2answers
68 views

Should API tests depend on each other?

I have an API I wrote that I want to test at the API level. Given that I'm testing from an external point of view, how can I manage data sets for each tests? The simplest solution I could come up ...
3
votes
1answer
183 views

What do you unit test in your angular applications?

I am currently working in a team, which, when I joined them did not do any sort of unit or integration testing. Over the last 2 years I have bit by bit pushed dotnet unit testing to a point where it ...
5
votes
2answers
384 views

Is it a bad practice for a unit test to “trust” the other?

Assume I have the following two functions: function storeObject(object) { // Connect to database // Prepare query // Execute query } function retrieveObjectWith(id) { // Connect to ...
-2
votes
1answer
60 views

Testing function that return objects

My web app is built around classes that I call widgets. Their goal is to be reusable and modular, to suit different scenarios. For example, I have a widget called BreadcrumbWidget which has two ...
0
votes
0answers
33 views

Unit testing an inductive problem? [duplicate]

I am developing a function that produces an inherently inductive output (calculating periods based on a start and end date). E.g., period n depends on the calculation on period n-1 and so forth. ...
1
vote
1answer
78 views

Persistence layer in the automated testing of an API

The automated tests of an API should be stable and simple. When writing automated tests for an API, we often have to check that the data created with a program implementing this API is persistent. If ...
0
votes
0answers
16 views

Testing Proxy with its service

I have a program that contains client and api logic. In summary client works like this: 1) Client handles client code 2) Calling the API is surrounded in (lets call it ) ClientService 3) if client ...
-2
votes
2answers
125 views

Is it possible to write unit tests for embedded systems with no prior embedded programming knowledge?

I have this question for a long time that is it possible for someone with no prior embedded systems programming experience to write unit tests? I have good knowledge of other languages like JAVA, ...
-4
votes
1answer
67 views

Any problems if we test every things on E2E?

I'm working on Flutter a project. We've test cases on the server-side. On the client-side, We have an idea to only test every acceptance criteria on the E2E level? The question is What're the ...
0
votes
1answer
40 views

Test logging library

I've been designing and developing a very scalable logging library for a while. The main goal of this library is pretty simple. Like many others projects, a simple goal does not mean a simple way the ...
1
vote
1answer
78 views

Is it better to test with dynamically generated input data or static data?

I have a little React app and I'm ready to test it. The first thing I need to do is to create some input objects with random data. I can proceed in one of two ways: I can create my own fake data line ...
4
votes
3answers
255 views

Testing unexpected inputs for unit tests and loops?

I'm working on an enterprise that has some Angular/Typescript projects and to avoid repeating code (basically copying and pasting) between them, we decided to go for Monorepo and start write an util ...
-4
votes
3answers
100 views

What can an assertion test that running the actual code cannot?

I'm currently learning Jest, Enzyme, Detox and testing in general, but I'm still trying to grasp the benefit of testing. From what I understand, testing is about creating hypothetical situations. Let'...
-1
votes
1answer
41 views

How to execute a proper comparative performance testing?

There are two compatible versions of the same Product (e.g. database engine) that I want to compare to each other for the same input scenario (SQL query). The problems that I want to address at first ...
1
vote
2answers
90 views

Is it a best practice or anti-pattern to export mock versions of functions for a library?

Context We are creating a library that makes an API (HTTP) request to a 3rd party. During testing we have written mock versions of the functions that make external requests so that we can test the ...
49
votes
15answers
8k views

Company outsourced testing; how can we encourage programmers to stop overly relying on testers?

A friend of mine is working in a 200-employee company. The company's business has nothing to do with IT, but they do have an IT department to work, among others, on their website, used by the ...
-4
votes
2answers
168 views

An idea about cooperation between development engineers and test engineers

Suppose we want to develop a small module (time needed: two weeks of one developer). Then what about this new (maybe?) pipeline: The test engineer starts working: Think about all cases (including ...
7
votes
2answers
277 views

Should examples for functions be unit tests?

I'm writing a python function to replace all the non-alphanumeric characters in the keys of this dictionary with underscores. To make sure it's working as expected as I don't have a ton of ...
2
votes
3answers
104 views

How to write Given/When/Then Scenarios without Given and When being the same

Given that I want to write a Given/When/Then scenario When I write a Given/When/Then scenario Then my Given and When are generally the same thing I've been trying to practice writing user stories in ...
0
votes
0answers
31 views

Shared stub or “private” stub for other modules in testing?

A methodology question again... Say we have an article module, a feed module, and a user module. We encapsulate them, so the user module only exposes one method User getUserById(int id) (all others ...
1
vote
2answers
81 views

Is “one representative” enough or need to have many same-type things in testing?

This is (again) a question of methodology... Suppose we are testing a service that returns Articles given ids, i.e. List<Article> getArticles(List<Integer> ids);. In addition, the ...
1
vote
1answer
93 views

How to Mock Test Data for complicated Integration/GUI automated tests

General overview We recently had lots of problems with automated tests in our team. Part of it was that the people designated to writing them had little experience. After this failed, we incorporated ...
-3
votes
4answers
361 views

How to break the vicious cycle of test-writing preceding an initial release?

I'm developing a FOSS library which I am pretty fond of. More specific details probably don't matter. I've already "finished" a feature set sufficient for an initial release IMHO. However - some of ...
6
votes
4answers
337 views

Exposing implementation details to tests

I have created a class that implements behavior which is difficult to test without some intimate knowledge of internal state. I'd like not to clutter the class's public API with accessors for this ...
2
votes
1answer
263 views

What is the origin of TDD?

I have seen people point me to many different "origins" of TDD. Some will point me to Kent Beck's rediscovery in the late 1990s with XP. Others will mention the 1960s best practice of annotating the ...
1
vote
1answer
35 views

E2E testing with third party services

I'm actually building an application that relies on multiple third parties (like 10-12) and I'm wondering if I should test my application with its third parties integrations. I had a discussion with ...
2
votes
2answers
208 views

Should powershell be used to develop a whole application?

We are automating the testing on an Web ERP solution (Dynamics) through a tool (RSAT, which uses selenium) provided by the developer of the ERP (Microsoft). The RSAT has a list of instructions to do ...
4
votes
2answers
213 views

Unit tests vs Automation testing

I'm a C# developer & never worked before on either unit tests or Selenium browser test automation. For a current assignment, there is an existing Visual Studio solution that has a project that ...
1
vote
2answers
88 views

Testing Environment Variables Strategies

I am in the process of implementing an API for the OPTIONS request for a pre-flight check on CORS calls. The Allowed-Origins host between local, test and prod will all be different so I moved this to ...
10
votes
2answers
374 views

Is it possible to test if/else trees properly without coding to the implementation?

I have been writing tests for a lot of long if/else trees recently, and I'm finding it a little discouraging. I want to speak in concrete terms, so consider the following example (I'll write in Ruby ...
0
votes
1answer
119 views

Architectural pattern for testable C code [closed]

I wrote a lot of software in C# and Python. I tried to make the overall architecture testable by using the "Clean Architecture" and Dependency Injection. This works well for C# (and python). Now I ...
1
vote
1answer
56 views

How can you do integration tests when launching multiple REST API instances of the same server?

Here's a simple scenario: a REST API of which you launch multiple, load-balanced replicas of the same service with Gunicorn. Unit and integration tests are run in single-instance cases, but how can ...
2
votes
0answers
60 views

A question about cyclomatic complexity

Assume the flow graph of a function is below (sorry I have forgotten the code of the function): And when I try to calculate the cyclomatic complexity: When I use the edge and node to calculate it, V(...
-1
votes
2answers
111 views

Why don't people usually use asserts throughout their application?

I usually do Javascript and I like putting console.assert liberally in my application. It throws an error if the first argument is falsey. E.g.: console.assert(price > 0, 'Price isn\'t above 0') ...
1
vote
1answer
67 views

Are integration tests for only the topmost level of a hierarchy of object compositions? Or for each level except the bottom?

Suppose we have a hierarchy like the following, where each thing under it means it is composed of that type: CarCompany | CarFactory | Car | Engine | +------+-----+ | ...
2
votes
3answers
673 views

How to maintain XML/JSON serialization tests?

It is quite common to test JSON / XML producing methods against file-stored expected output (at least in Java world, but probably in other environments, too). For instance there's a method that ...

1
2 3 4 5
26