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
4 answers
4k views

Should test resource files be stored inside the Java class source directories?

In a TDD (Test-Driven Development)-based Java project built by maven, lots of classes needs to be tested with text-based input files such as .csv. At the beginning, I put them into the src/test/...
Rui's user avatar
  • 1,925
-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
5 votes
5 answers
464 views

Can we add methods which is easier for assertion in test and which is only used in tests when TDD?

Here let me take a simple parking boy example. A parking boy can manage several parking lots, and when a car comes, he will park the car into some parking lot and can also help to un-park the car. ...
Freewind's user avatar
  • 151
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
15 votes
6 answers
3k views

Is creating the objects you think you will need ok in a first test in TDD

I'm fairly new to TDD and I have trouble when creating my first test when it comes before any of the implementation code. Without any framework to the implementation code I am free to write my first ...
Encaitar's user avatar
  • 3,085
17 votes
3 answers
43k views

How to test the data access layer?

I have a DAO method that utilizes Spring for JDBC access. It calculates a seller's success rate of selling an item. Here is the code: public BigDecimal getSellingSuccessRate(long seller_id) { ...
Michael's user avatar
  • 273
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
-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
70 votes
7 answers
28k views

How to deal with static utility classes when designing for testability

We are trying to design our system to be testable and in most parts developed using TDD. Currently we are trying to solve the following problem: In various places it is necessary for us to use static ...
Benedikt's user avatar
  • 891