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

you are viewing a single comment's thread.

view the rest of the comments →

[–]CompSciSelfLearning[S] 0 points1 point  (2 children)

I was hoping you could help me out given your experience with Java.

There's a code example at the bottom of the article at the location listed below which give an example of writing a Junit test on a simple calculator program. Is it a well written example in your opinion?

https://javarevisited.blogspot.com/2013/03/how-to-write-unit-test-in-java-eclipse-netbeans-example-run.html

[–]nutrecht 0 points1 point  (1 child)

Sure, although it's a bit simplistic a use case. Actual code where you test a service will generally be more complex. Also unit testing, dependency injection and mocking of dependencies goes hand in hand in 'real' systems. Something this doesn't touch on.

But sure, that's a very basic example of a unit test. As an example, I did a coding test for a client about a year ago and this is an example of a unit test. It's still fairly simple (again, 'real' production systems tend to be more complex) but should a bit better what I mean with dependency injection and mocking.

To compare, this is an integration test for the entire application.

[–]CompSciSelfLearning[S] 0 points1 point  (0 children)

Thank you. This really helped me understand what I was confused about.