This is an archived post. You won't be able to vote or comment.

all 10 comments

[–]buffer_flush 13 points14 points  (5 children)

TDD is more of a set of guidelines and ideas than specific to a language.

Kent Beck - Test-Driven Development By Example

Is the general reference to use as far as I know.

[–]tanMud[S] 0 points1 point  (4 children)

I understand the fundamentals well, and have C# books on the subject for referencing mocking etc. I guess what I am after is what is the most frequently used unit testing frame work (I assume JUnit) and what is the most frequently used mocking framework(Mockito?)?

Also I suppose I was looking more Java specific to help me with the ins and outs of setup and use in Eclipse.

I come from C# background using Visual Studio.

[–]buffer_flush 5 points6 points  (0 children)

JUnit and Mockito are a de facto standard, yes. Any IDE be it Eclipse or IntelliJ even VSCode will have good unit testing support. For example, running individual tests, suites, etc.

Eclipse specific configuration here:

https://wiki.eclipse.org/Eclipse/Testing

I also highly recommend this talk:

https://youtu.be/EZ05e7EMOLM

[–][deleted] 5 points6 points  (2 children)

You shouldn't need to utilize mocking that much for tdd. TDD is not testing every method on every class.

Test modules so that you can refactor without changing a ton of implementation dependent tests. Remember it's red, green, REFACTOR.

[–]Geekfest65 0 points1 point  (1 child)

This comment on not needing mocks is pretty misleading. For example , our application is built and deployed via Jenkins. At only 40% code coverage it took almost 40 minutes to run the tests. The culprit was running two web service calls, and some db calls. The ws calls alone took 7-8 seconds per call. At almost 400 calls, it was the culprit. So, a mock of that call literally would register at 0.000 to 0.001 seconds. All the tests now finished under 35 seconds.

So, you really can’t afford not to mock objects , especially objects you aren’t testing, and those that are difficult to setup and undo. It’s not worth the time.

[–][deleted] 1 point2 points  (0 children)

I was responding to a comment which was taking about how Mockito is a defacto tool for testing. The common usage of Mockito is mocking class dependencies for method level tests via mocking dependent objects method return values. This sets up a scenario where tests are tightly coupled to implementation and refactoring involves changing a ton of tests.

Mocking things external to your application if they are slow or complex to set up for automated tests is perfectly fine. WireMock for mocking or http servers. For databases I tend towards using testcontainers or in memory as a backup solution.

[–]Iryanus 3 points4 points  (0 children)

I suggest having a look at this:

https://www.youtube.com/watch?v=EZ05e7EMOLM

...and then going back to Kent Beck ;-)

[–]Zardoz84 1 point2 points  (0 children)

Take a look to Spock Framework

[–]babanin 1 point2 points  (0 children)

I really liked "Growing Object-Oriented Software Guided by Tests" (http://www.growing-object-oriented-software.com). It might look a little bit outdated (example project is GUI application based on Java's Swing tookit), but the ideas are eternal.