Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
2 votes
1 answer
576 views

Basic Ticket booking code with Unit tests

I am going to run a session for a few other developers who are new to Junit, mocking, etc. I have designed a very simple application with classes and tests to demonstrate how to do unit testing. ...
HariHaravelan's user avatar
0 votes
1 answer
95 views

First time writing tests (Service Layer)

Service class: ...
GodLike's user avatar
  • 51
1 vote
1 answer
390 views

Testing a service that makes database calls, without a database

I'm working on a new service, for the past year I haven't needed to write tests from scratch. I've either been bug fixing, or adding features that require modification of tests, but not writing ...
mal's user avatar
  • 313
4 votes
1 answer
16k views

Mock Entity or DTO for unit tests [closed]

Is this good approach, to mock some domain object, for example javax.persistence.Entity, or DTO (data transfer object)? Below is ...
Yaroslav Boichuk's user avatar
2 votes
1 answer
778 views

Testing controller class using mockito mvc

I'm beginner java programmer and would like to ask you to take a look at my code. I wrote small rest service among with tests. Now I have to questions to ask. The test methods: ...
filemonczyk's user avatar
3 votes
2 answers
269 views

Unit test for a method that adds tweets to a database

I have a class which inserts a list of tweets to a database table and also inserts the tweet's key with the associated filter's key to a many-to-many table. I am testing the sole public method of this ...
Aki K's user avatar
  • 1,329
4 votes
1 answer
81 views

Unit Testing and good use of matchers

I been having discussion with colleagues recently about good use of matchers. Consider the following sample: ...
npmaster's user avatar
1 vote
1 answer
55 views

Testing class that transforms JSON into a spreadsheet

I am creating unit tests but the class uses objects that have long JSON. What can I do to improve the readability of this? In tests, only insert those JSON really needed for the test. The class I ...
Daniela Morais's user avatar
4 votes
2 answers
8k views

Using Mockito to verify that an object is saved

We've been reviewing some legacy code and have found differences in the preferred approach to how to write tests using Mockito. Both the following tests pass but which one is better and why? ...
FinalFive's user avatar
  • 141
2 votes
1 answer
261 views

How to test "verification flow" code? would you test this at all?

I want to write unit-test to my code. However, while writing it, it seems all I can verify is that one method or the other were called once. My class is a manager that execute verification flow. It ...
Elad Benda's user avatar
5 votes
3 answers
14k views

Unit testing a servlet in a meaningful way

I have to write a unit test for the method processRequest in the servlet below and I'm wondering if: It just shouldn't be done. The class should be rewritten / ...
DiePartei's user avatar
  • 151
1 vote
1 answer
528 views

Is building a test instance from a mix of both mock and real objects OK?

I am new to android testing and would like to try start off in the correct direction, so I am trying to understand if this is the correct way to test a particular method or if there is some best ...
nPn's user avatar
  • 165
1 vote
1 answer
1k views

State and Interaction based testing using jMockIt

I am new to jMockIt and so wanted to learn it. I thought of implementing a synonym servlet kata. The servlet takes a word as input and returns the synoyms of the words as a comma seperated string. The ...
Anand Patel's user avatar