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 ...
26
votes
6answers
12k views

Testing: deterministic or non-deterministic?

Is it better to have either a Deterministic test suite, that results in the same tests succeeding Non-deterministic test suite, which potentially possibly covers more cases ? Example: You write a ...
0
votes
10answers
636 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
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, ...
13
votes
3answers
4k views

All unit tests in one executable, or split them up?

When writing tests for one piece of software, say a library, do you prefer to compile all unit tests into one, or separate them into several executables? The reason I'm asking is because I am ...
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
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
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 ...
-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 ...
-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 ...
5
votes
1answer
366 views

Determining if webgl code will work on a variety of hardware

I have some javascript/webgl code. I want to have some idea of whether it will work for someone with a different browser/machine/gpu. This is difficult, because there's so much diversity in support ...
19
votes
7answers
25k views

Should each method have a separate JUnit test class?

I am writing JUnit unit tests for my classes. Is it better to have a separate class for each method, or have just one test class for every actual class?
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 ...
2
votes
1answer
207 views

Which git workflow for micro-services and testing

I would like to know what best practices exists out there with regard to micro services, CI/CD, testing and Git workflow, especially the way of working given the constraints that a) nothing should ...
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 ...
9
votes
2answers
513 views

Boundaries of unit testing between my code and a library or sub-component

Background: I am new to testing in general, and have been studying it in context of JavaScript, specifically React.js, front-end development (actually new to this as well). For the question, I have ...
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 ...
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 ...
24
votes
9answers
6k views

How do you scale your integration testing?

I am investigating techniques and strategies for scaling our growing number of integration tests on our current product, so that they can (humanly) remain part of our development, and CI process. At ...
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 ...
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....
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. ...
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 ...
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
1answer
120 views

Should snapshot tests compare against stored test data or data from a database?

I have a method GetReportAsync that takes one XML and generates another: public async Task<string> GetReportAsync(string id) { // Get Order.xml from a file database var order = await ...
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) ...
110
votes
14answers
29k views

Should I avoid private methods if I perform TDD?

I'm just now learning TDD. It's my understanding that private methods are untestable and shouldn't be worried about because the public API will provide enough information for verifying an object's ...
30
votes
5answers
7k views

Do unit tests sometimes break encapsulation? [duplicate]

I very often hear the following: "If you want to test private methods, you'd better put that in another class and expose it." While sometimes that's the case and we have a hiding concept ...
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 ...
-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 ...
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 ...
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 ...
0
votes
1answer
317 views

How can we better maintain a large amount of DbUnit datasets?

The project I'm currently working on a Spring Boot project, and I have a question regarding testing against the database. Our testing tech is currently JUnit 4, Mockito and DbUnit, and we test ...
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 ...
1
vote
2answers
482 views

Selecting test cases to run by checking what's changed

Problem: If running all test cases takes too long, I manually specify a subset of tests to run while developing. But when I finally push to CI, it can happen that I broke some other tests or a ...
-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). ...

1
2 3 4 5
28