Tagged Questions
35
votes
8answers
12k views
How do you unit test private methods?
I am working on a java project. I am new to unit testing. What is the best way to unit test private methods in java classes?
27
votes
5answers
2k views
I want to start using TDD. Any tips for a beginner?
I never used an automated test mechanism in any of my projects and I feel I'm missing a lot. I want to improve myself, so I have to start tackling some issues I've been neglecting like this and trying ...
23
votes
1answer
442 views
How have Guava unit tests been generated automatically?
Guava has unit test cases automatically generated:
Guava has staggering numbers of unit tests: as of July 2012, the
guava-tests package includes over 286,000 individual test cases. Most
of ...
12
votes
2answers
428 views
What are some good books/resources/ways to learn TDD? [closed]
As a grad student, I haven't really written anything to test my code. Usually what we do is just run the code on some test input and if the output result looks okay or as we expected then we just ...
8
votes
2answers
750 views
design pattern for unit testing? [duplicate]
I am beginner in developing test cases, and want to follow good patterns for developing test cases rather than following some person or company's specific ideas. Some people don't make test cases and ...
7
votes
6answers
2k views
What unit test frameworks exist for Java?
I've used TestNG and JUnit. What other frameworks are out there? What makes them special and/or different from the rest?
7
votes
3answers
471 views
What elements of my JUnits should I mock?
My classes are following this structure
Service Tier (creates and maps InputDTO to DB Data) ->
DAO Tier (actually executes DB calls)
When I write the service tier JUnits, and when it calls DAO ...
6
votes
3answers
525 views
Mocking concrete class - Not recommended
I've just read an excerpt of "Growing Object-Oriented Software" book which explains some reasons why mocking concrete class is not recommended.
Here some sample code of a unit-test for the ...
6
votes
4answers
2k views
What are some best practices for populating and using a test database?
So, I'm developing some database-driven RESTful Java web services, using Hibernate and MySQL. For testing purposes, I'm using the H2 in-memory database. H2 is nice and fast, so this has worked out ...
5
votes
3answers
277 views
Should a unit/integration test that may result in an infinite loop have a clear assertion?
Unit: A multithreaded unit reads data of a queue and processes it, sending it off to another queue. When the last item is processed (null value found) the process stops.
Test: Place a set of known ...
5
votes
2answers
907 views
Write Unit test for heavily-database application?
I'm currently developing a Spring-based web-application, in which almost every operation create/update/delete something in the database. The logic mostly about checking condition so as to we should ...
5
votes
4answers
4k views
Which JUnit 4 book do you recommend?
Can anyone recommend a good book on JUnit 4?
I've done some stuff in JUnit 3 before (mainly changing other people's tests) so I'm not completely new to the idea, but I've not done any testing with ...
4
votes
7answers
477 views
Is mocking for unit testing appropriate in this scenario?
I have written around 20 methods in Java and all of them call some web services.
None of these web services are available yet. To carry on with the server side coding, I hard-coded the results that ...
4
votes
3answers
234 views
How to invoke anonymous functions in testing?
Below is Java code.
I need to cover the below function. I searched for many websites, but I still have no ideas. Is there any methods to cover the override anonymous classes?
public static void ...
4
votes
1answer
133 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 ...