Skip to main content

All Questions

Tagged with
0 votes
3 answers
434 views

Would you test this piece of configuration code? How do I determine which code is worth testing?

We have a piece of code that decorates an interface to transparently add retry logic. Inversion of Control configuration service.AddOurRestApiClient() .AddResilienceHandler("Retry", ...
LostInComputer's user avatar
1 vote
2 answers
342 views

Best Practice: Unit test coverage vs. in-method sanity checks [duplicate]

I have a code-coverage requirement of of a certain percentage, and face the following tradeoff: Should I sacrifice in-method sanity checks and error handling for ease of (unit-) testability? Lets ...
MPIchael's user avatar
  • 269
-1 votes
3 answers
1k views

Should methods with business logic be made private? [duplicate]

So I am writing a project using Spring Boot. All of my logic resides in @Service classes. I have separated each service class based on entity. For example - If I have two independent entities A and B, ...
rsp's user avatar
  • 143
6 votes
3 answers
7k views

What is recommended way to create test data for unit test cases?

I am new to TDD/unit testing. I am going to write a complex scheduling algorithm in Java. As this module is a core part of our application and there are number of scenarios in it, I want to write ...
Bhushan's user avatar
  • 215
5 votes
3 answers
2k views

Is this unit test too tightly coupled to implementation?

I believe the existence of this unit test is justified. However, to me, this unit test seems very coupled to the method implementation, though I'm not sure it can be improved upon. class ItemManager {...
user39846's user avatar
  • 191
-3 votes
3 answers
316 views

What is the most elemental workflow for TDD?

Gradle is such an interesting build tool that it prompted me to look at Spock and JUnit -- which I've never done before. What is the basic workflow with TDD? My approach has been to do frequent ...
Thufir's user avatar
  • 224
2 votes
2 answers
3k views

Ways of creating expected object for assert

Recently, I started to use TDD. It's really cool and fun but creating expected object for assertEquals is very boring and tedious. At the moment I see only two way for that: Straightforward Creating ...
Vladislav Koroteev's user avatar
11 votes
1 answer
15k views

Testing private methods as protected

I was reading this answer about testing private methods and it mentioned several possibilities: extract methods as public to another class make them public separate the env of test and production so ...
sam's user avatar
  • 221
10 votes
3 answers
11k views

Advantage/Disadvantage of having all variables declared in a JUnit Test

I've been writing some unit tests for some new code at work, and sent it off for a code review. One of my co-workers made a comment about why I was putting variables that are used in a number of those ...
Zymus's user avatar
  • 2,533
22 votes
4 answers
3k views

How can I use unit tests and TDD to test an app that relies mostly on database CRUD operations?

At work, one of my projects is mostly about taking data passed in from an external client and persisting it in a database. It's a Java enterprise app using JPA and most of our logic revolves around ...
Daniel Kaplan's user avatar
1 vote
1 answer
214 views

Test Doubles : Do they go in "source packages" or "test packages"?

I've got a couple of data access objects (DefaultPersonServices.class, DefaultAddressServices.class) which is responsible for various CRUD operations in a database. A few different classes use these ...
sbrattla's user avatar
  • 793
1 vote
1 answer
5k views

Is it worth writing a unit test for a DTO with the most basic getter/setters? [duplicate]

The advantage is it protects your DTO against future "enhancements" ?
NimChimpsky's user avatar
  • 4,670
21 votes
1 answer
4k views

Is there a modern replacement for a mutation testing tool like Jester for Java?

“Why just think your tests are good when you can know for sure? Sometimes Jester tells me my tests are airtight, but sometimes the changes it finds come as a bolt out of the blue. Highly ...
Geek's user avatar
  • 5,217
3 votes
2 answers
255 views

Do I need to learn python first to understand the part 2 of the book Test Driven development?

It seems like Python is used as a coding language for part 2 of Kent Beck's book Test Driven Development. I have read the first part of that book and started appreciating the value of TDD . First part ...
Geek's user avatar
  • 5,217
-2 votes
2 answers
873 views

How can I test database access methods in Java? [closed]

I want to write a test for a method that accesses a database such as following. public class MyClass{ public String getAddress(Int id){ String query = "Select * from Address where id="+...
javaStudent's user avatar

15 30 50 per page