Questions tagged [testing]

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

Filter by
Sorted by
Tagged with
18
votes
4answers
3k views

Dry running a function

I have a function with a sensitive operation: function doSomeThingSensitive() { customers = getAllCustomers() for each customer in customers if customer is from Europe Give ...
2
votes
3answers
191 views

Still don't understand when to mock and when not to

I've been trying to understand when to mock and when not to mock, however I'm not able to come up with a consistent guideline and I'm hoping to get some input on the subject. Let's look at the ...
0
votes
2answers
100 views

On hanging Desktop-applications

I am filled with questions pertaining to the situations where a desktop-application hangs, possibly for minutes. I've got this complicated game-engine written in c++. Several times during development, ...
0
votes
0answers
55 views

What is the correct approach to test CDI classes in service layer?

My app has a service layer which is composed by CDI @ApplicationScoped beans. This is a class extracted from my project: @ApplicationScoped public class PostService { @Inject private ...
0
votes
1answer
137 views

Should i specify that my methods "throws ConstraintViolationException" if the exception is actually thrown by a CDI interceptor?

Here is a sample method: @ApplicationScoped public class MyClass{ public void getUser(@Min(1) int id){ //get User logic } } I'm in a CDI environment with @ValidateOnExecution(type = ...
0
votes
3answers
168 views

Should test cases show desired behavior or actual/current behavior, or can they do both?

Let's say I want to add tests to a software that has some flaws/bugs. I want to add the tests before I fix the bugs. And I want to actually merge them in the main branch, not just have them in a ...
-1
votes
2answers
102 views

Unit testing inside the main project [closed]

Usually, unit tests are built in a separate project/executable. Ideally, components under tests should have a small number of mockable dependencies, allowing us to do this, among other benefits. But ...
0
votes
10answers
639 views

Testing : Why is it necessary?

Hello I will try to explain what is my actual understanding of tests and why I have problems to grasp it's utility. Even if I try my hardest to understand the concept of TTD, unit test, integration ...
-2
votes
2answers
95 views

Best practices around writing testable extension methods

I’m currently working in C# and I’d like to write and extension method against a type. There is a small amount of repeated logic between classes surrounding JSON deserialization, using the ...
-2
votes
2answers
76 views

Should application state be tested when testing Api?

I am trying to adpot a TDD process. I am a bit confused when it comes to testing an Api. I know for sure that the status and the response should be tested. But I am thinking if whether or not I should ...
0
votes
1answer
51 views

Isolated Integration Tests in Layered Software Architecture Pattern

Let's say we have a simple application that uses a popular approach as Controller -> Service -> Repository pattern under a framework. We would like to write integration tests and start from ...
0
votes
1answer
70 views

Refactoring business logic out to private methods and testing

I am currently working on a project where there is a class ContactMonitoringJob a Quartz IJob class​ which in brief keeps pulling from a database and checks if any new changes have been introduced ...
0
votes
1answer
102 views

How to test adapter code?

I write a software which trades with crypto currency via big exchanges. Using the clean architecture approach I have defined some core entities, some business cases and then created an outer ring of ...
0
votes
3answers
236 views

Should I unit test functions internally used by API I expose?

I'm writing a CRUD app in Python that exposes web API. At first I wrote functions for communicating with DB and wrote tests for these functions. def crud(): # do something with db def test_crud(): ...
0
votes
0answers
85 views

Trade-off between usability and clean design

I have designed our in-house hardware testing framework. My goal is to ultimately release the framework into the public domain. Early on, my foremost design criterion was to provide a powerful yet ...
1
vote
1answer
127 views

Should I check floating point values in a unit test?

We have unit tests that are running some underlying model. We provide it with some test input, and receive some outputs + floating point scores. What's a good practice from a unit-testing standpoint? ...
3
votes
1answer
81 views

Structuring user story tests with variations

I'm writing the sort of tests which go through a whole user scenario e.g. User clicks "edit profile" User edits their name etc. However, I find myself needing often needing to test small ...
1
vote
1answer
118 views

How to test functionality that requires a certain internal state?

I'm struggling to test functionality in a class where the class has to be in a certain state for the functionality to work, but the class cannot be put directly into a given state by design, to ...
1
vote
2answers
66 views

Is the use of third party software and network requests the motivation for integration testing?

I'm wondering if the use of third party software and/or network requests is the motivation for integration testing? For the sake of keeping the code examples minimal, I'll define a unit test as ...
0
votes
0answers
30 views

Test strategy for liquibase changes

I am part of a team that works on a SpringBoot application and we use liquibase for maintaining our database changes. Config data that has to be added/removed/modified goes as part of a change-set. ...
3
votes
3answers
344 views

What to call tests that check that output has not changed?

This is a question about terminology, not about method. Our application consists of physical simulations. Results have been validated in various ways, but we have no oracle that guarantees correctness....
3
votes
1answer
147 views

Is it necessarily a code smell to programmatically create expectation models for test cases?

I'm responsible for staging some tests, against some members, namely against the rates that are due for them. After talking about it with my peers, I see the members are a function of three other ...
0
votes
3answers
387 views

Should I test an all mocked method?

I have a similaire scenario: int retrievePrice(string productName) { string id = restApi.get("productid", productName); return restApi.get("productprice", id); } The restApi ...
1
vote
2answers
112 views

How to avoid unit test duplication in wrapper classes?

Assuming I’ve a class with three methods, startCollection, add, endCollection. One test case is: if start was not called, add should return an error. I’ve mocked the persistency storing the state with ...
0
votes
2answers
124 views

Platform that converts Documentation into Unit/Integration Tests? [closed]

I've seen many SO questions around auto-generating unit tests, or documenting unit tests, but I'd like to go the reverse direction. What I'd REALLY like is to have folks (devs, tech writers, etc) ...
5
votes
3answers
251 views

Where to specify mock behavior in Given-When-then syntax?

I am unsure where/how to specify the behavior of a mock in a test scenario when using the Given-When-Then syntax. It seems to me both Given and When could be correct. Consider the following example: ...
2
votes
1answer
140 views

Setting up tests and a continuous integration pipeline in a polyrepo environment

In the past I've mainly worked with monorepos, specifically a Vue.js app that was served by a rails backend. Setting up E2E/integration tests in the CI was simple, because all the required parts were ...
0
votes
1answer
75 views

ASPICE assessment: detail of test logs

The "VDA Automotive SPICE Guidelines" (excerpts: https://vda-qmc.de/fileadmin/redakteur/Software/Automotive_SPICE/Veroeffentlichungen/VDA_Guideline_Rules_and_Recommendations_2017.xlsx) tells ...
-1
votes
1answer
70 views

How to black-box test transaction atomicity?

Suppose we need to ensure that a sequence of database operations - currently implemented as A followed by B followed by C - executes either all together, or not at all. We can achieve this using a ...
3
votes
3answers
161 views

Etiquette / Leadership / Sharing Best Practices - How much should I try to influence?

I recently joined another team part time where I kinda know several of the people, and they know me for my design work mostly, but I'll be doing design and some development with them. There's a lot of ...
18
votes
3answers
2k views

How do you test and demonstrate that you have properly prevented a race condition? [duplicate]

Suppose I'm building a web application using Django. Some of the views need to touch multiple database tables or rows, and there is some kind of state consistency that I need to ensure among the ...
1
vote
2answers
274 views

With Kent Beck's "test && commit || revert" (TCR), do you skip the "red" of "red, green, refactor"?

If you haven't heard of Kent Beck's TCR, it can be summarized with this: any time your tests go green, you commit; anytime your tests go red, you git reset --hard. This post is about how to practice ...
-2
votes
2answers
837 views

How to Unit test a class that saves a file?

I am writing a class that has one function that I want to test. The function, textToPdf, takes a list of text files and creates and saves a PDF at the file path argument. In order to test that this ...
0
votes
2answers
144 views

If my API depends on a third party OAUTH2 provider (Microsoft) - how do I write tests to test my API endpoints?

this is a followup question to the following StackExchange question - If you had a medium size company, several developers - but zero tests written in your REST API's - where would you start? At the ...
5
votes
5answers
521 views

If you had a medium size company, several developers - but zero tests written in your REST API's - where would you start?

I am looking to identify a benchmark to shoot for, and to come up with a decent game plan for introducing tests into our systems before deploying new code. Just some backstory My employer is not a ...
2
votes
3answers
189 views

Given a function that has already been unit tested, but is present in another unit, should I bother testing it again?

Say, for instance, I have this simple function in my domain layer: function canCreateNewUsers (principal: User): boolean { return principal.isSuperAdmin || principal.isAdmin // || ... a bunch of ...
4
votes
9answers
465 views

Should I be enforcing lint rules on feature branches?

I am working on a project and I typically setup precompile git hooks for things like linting and testing. I recently had some consultants we use complain about requiring lint on every commit. Their ...
-1
votes
2answers
132 views

What is the current definition of continuous integration?

It seems that there are at least two possible definitions of continuous integration: Frequent merging of a codebase to a common codebase (e.g. daily merge to the main branch of a VCS server). ...
0
votes
0answers
25 views

How to test integration with third party libraries on the backend from the frontend?

What is the standard or recommended approach or architecture for testing integration to third party libraries? More specifically, for this post I am only concerned with one of the possible ways of ...
1
vote
2answers
94 views

Where shall we start mocking?

Scenario: Our CLI-script downloads data Therefore, amongst other things such as pre/postprocessing, it calls a function from another (internal) python package (which is maintained by another group) ...
0
votes
0answers
22 views

Design a multiple Asp.Net Core apps Solution

I am having an .Net Core Solution consisting of 3 Projects: The Site (Asp.Net Core MVC WebApp) The API (Asp.Net Core API) The "Common" library for shared functionality. The Common library ...
0
votes
4answers
467 views

How to effectively unit test code with lots of database dependencies?

I find myself writing a lot of boilerplate mocking code for my unit tests. I think there must be a better way. Background I am working on a project that relies on complex configuration that is stored ...
58
votes
5answers
8k views

Is the usage of random values in unit testing a good practice? [duplicate]

Having worked in complex solutions that had Unit Tests and Integration Test in the CI/CD pipeline, I recall having a tough time with tests that failed randomly (either due to random values being ...
3
votes
1answer
117 views

Simulation Testing: how to test something that depends on its previous state

I'm practicing test driven development while implementing a network simulator: devices communicate with each other and implement little bits of functionality that respond to messages. Each device has ...
0
votes
2answers
158 views

Does PUT need to be idempotent?

It has been said that "PUT is idempotent": The difference between PUT and POST is that PUT is idempotent: calling it once or several times successively has the same effect (that is no side ...
0
votes
4answers
203 views

Change architecture design to API to reduce coupling

I was reading articles about TDD and I found the following one. https://blog.cleancoder.com/uncle-bob/2017/03/03/TDD-Harms-Architecture.html In order to answer this question I think someone should ...
0
votes
1answer
80 views

Best practices for seperating/designing classes and methods for use in testing

I run unit and integration tests on my system. These create, start, stop and delete Docker containers. I want the exact same state in my Docker environment at the end of the tests as I had at the ...
0
votes
2answers
114 views

How to check the output of a program in black-box testing?

As part of a black-box testing activity, I would like to check the executable I'm testing generates a binary file that responds to its specifications given a specific input. I'm wondering how I can ...
1
vote
0answers
111 views

Integration Testing Stripe Payments - stripe-mock or Stripe's test mode?

I'm building an automated test suite to integration/feature test my organization's Stripe implementation within a GitLab CI pipeline. We're running Laravel 8 and using phpunit for testing. Within this ...
-2
votes
1answer
81 views

Is it necessary to test a TDD-based API in 3rd party app like Postman?

I just finished my TDD-based REST API. And I would like to use Postman to document it for the frontend team until I realized it has its own test script. Now I'm wondering, is it necessary to double ...

1
2 3 4 5
28