Tagged Questions
6
votes
2answers
131 views
Testing quicksort user input
I am testing a quicksort implementation. Arrays of random size with random data are passed to quicksort and the return time is averaged out. The user is prompted to enter values for
minimum length ...
7
votes
1answer
59 views
JUnit extending abstract test class
I have been thinking quite some time and asked an StackOverflow question about extending abstract test classes, but I haven't been able to do it until now.
I'll list my approach and then discuss some ...
6
votes
1answer
39 views
FuseMonsterAction implementation and unit tests
I'd like to get a general review on the following code, and I'll highlight an extra point below:
...
6
votes
2answers
201 views
Create better Unit test
Question: Is there anything you could do in order to improve the test?
I am using Spring Framework 4, Hibernate 4, JUnit 4. All DAO unit tests inherit from TestDaoSetup class:
...
10
votes
2answers
96 views
Unit tests for an argument-checking class
I am wondering if my current unit tests could be written better, I am most interested in whether it is possible to make the code look more concise, as currently it a boiler-plated mess.
I have full ...
15
votes
3answers
465 views
Writing better JUnit tests
I am using Spring Framework, Hibernate and JUnit. I am testing persisting of a UserEntity.
The UserEntity has the following associations:
ManyToMany - City
ManyToMany - ActivityCategory
ManyToOne ...
10
votes
1answer
157 views
Markup calculator application using MVC
I want to make sure that the code is correct in terms of its design, code correctness, best practices & Junit testing.
The complete description is given below:
Functioning of the app quickly ...
12
votes
3answers
203 views
Trading Card Game's Hand class and tests
As part of a Trading Card Game, I have created a Hand that will need to hold all cards that a player currently has in his hand. The code is built using Java 8.
The ...
10
votes
4answers
313 views
Schedule class (exercise for test driven development)
Schedule is a simple class that could be used in program to manage when a task should be repeated (a todo list, for example). Its constructor requires a start date and an optional end date. Then type ...
9
votes
2answers
284 views
Using a Pythonesque range() generator function with the Java foreach loop
Now that we have the nice new foreach loop in Java, the old-style loop looks ugly be comparison.
I like the way Python has a range() generator that allows the ...
18
votes
4answers
1k views
Just a lowly counter that turned out to be surprisingly complicated
While writing this review, I saw a need for a Counter object similar to Python's. It seemed like it would be easy to write such a class, but it turned out to be ...
8
votes
3answers
808 views
Simple Hello World with unit tests
This is a simple hello world sample project used for instruction. I'm just looking for general comments on the approach and design.
AdvancedHelloWorldTest.java
...
5
votes
2answers
104 views
Is the public interface easy to use and the documentation understandable? Are the unit tests well-written?
I have a year or so of experience in developing in Java. I submitted the solution for this task, but never got the feedback that was promised. Since I still would like to get a feedback on my ...
4
votes
1answer
120 views
Simple class to represent progress
Progress class was written using TDD.
Interface of this class (pseudo-code):
...
4
votes
2answers
80 views
Review of java interface for constructing brain model
I have built a partial human brain model and the following is an example of how I use all the classes. I was wondering if anyone could critique my implementation strategies because I feel like the ...
6
votes
2answers
451 views
Simple calculator for an interview
Question: Simple Calculator
Input loaded from file. Instructions can be any binary operators.
Ignore math precedence. Last input is apply and a number e.g. "apply
5". Calc is then ...
1
vote
2answers
103 views
1
vote
1answer
35 views
Proper way of a testable method with multiple return points [closed]
I have the following piece of java method code:
...
2
votes
2answers
132 views
1
vote
3answers
57 views
Is my code unit testable
I've written a piece of code. Would like to know is the below piece of code unit testable or does it need any kind of refactoring.
MatchCilentUrls is the primary method for matching two urls. Based ...
4
votes
1answer
611 views
Unit test an ExecutorService in a deamon
To execute tasks sequentially with a timeout I use ExecutorService.submit() and Future.get(). As I don't want to block calling ...
3
votes
1answer
70 views
Guice custom behavior for testing, how is this solution?
I have a Java/Swing/Guice application that uses multiple frames. When the application runs normally, I just want some of these frames to hide (and the "master" frame can unhide them).
When testing ...
2
votes
2answers
566 views
Mocking utility class for database testing
I have these classes that have a boilerplate way of initialization. So, instead of writing it each time, I wrote a class called MockUtil.java, and I put the ...
4
votes
1answer
258 views
Help with comparison counters in quick sort algorithm
At the suggestion of @templatetypedef, I am posting the code for my quick sort to see if anyone can offer suggestions as to where to make comparisons. And any tips on improving the code. I am using ...
1
vote
2answers
88 views
Unit Test to verify number of times lazy initialization logic is executed for a data member
I'll write a small simulation of my actual class first to request insights on unit testing one of the behaviors of this class. Here is my class A:
...
3
votes
2answers
182 views
How can I optimize this code for unit testing
How can i optimize this code with less number of loops and return values for unit testing
...
3
votes
2answers
268 views
Code to redirect console IO to strings
This code allows calling a method while redirecting the IO to strings. This is useful for unit testing where you have to direct something to the console or examine output that comes from it. I ...
4
votes
1answer
572 views
Ranking and sorting on Array/List
My apology, I am quite new to posting a question in this forum.
I had a task where I was supposed to write a solution to sort entries(Name, score - in an array/list) in order of score and generate ...
3
votes
1answer
137 views
Designing a listener method and making it Testable
I have a java based server application that needs to support multiple clients. In the main class I have a method that runs in an infinite loop and waits for client connection. Following is this ...
2
votes
2answers
980 views
Tesing a simple calculator class with JUnit/JMock
I'm playing around with JMock and trying to understand whether I understand the idea correctly.
There's an interface Printer aimed to print integers somewhere. ...
2
votes
1answer
168 views
Spotify Best Before puzzle
I thought to spent my free time by solving a puzzle: Best Before Spotify Puzzle.
I coded in Java, and yeah I did not clean up my code (just a rough work) and I have yet to optimize... so I did check ...
3
votes
2answers
1k views
Robust logging solution to file on disk from multiple threads on serverside code
I have implemented a socket listener that runs on my Linux Ubuntu server accepting connections and then starting up a new thread to listen on those connections (classic socket listener approach). ...
2
votes
2answers
199 views
How to use inversion of control within a strategy when using the strategy pattern
I am creating a skeleton application to demonstrate use of the Strategy design pattern and inversion of control inside a Strategy.
The application is the backend of a simple board game, which also ...
1
vote
1answer
138 views
How should I test this class?
I've been trying to figure out how to (reasonably) test a builder-type class I've created, or whether (and how) I should refactor some portion of the design.
Specifically, I created a builder ...
4
votes
2answers
784 views
Rounding a date to a dynamic unit of time, using only JDK 6
Question originally posted on Stack Overflow here.
I'm trying to do an elegant round method that only use the JDK methods and leverage the TimeUnit class of that ...
5
votes
2answers
1k views
Ways to improve my coding test FizzBuzz solution for a TDD role?
I had an interview recently where I was asked to produce the traditional FizzBuzz solution:
Output a list of numbers from 1 to 100.
For all multiples of 3 and 5, the number is replaced ...
1
vote
2answers
194 views
Question on where to put code logic
I am developing a small compiler like tool. In the process, I wrote a Class<?> wrapper, JavaClass:
...
3
votes
2answers
481 views
Please Review my Generic Linked List Implementation in Java
I am looking for feedback on my Doubly Linked List implementation that I have written in Java. I am looking for specific feedback on the efficiency of my code, as well as my usage of generics. I am ...
1
vote
2answers
99 views
FooTest or FooTests? [closed]
Can't make up my mind. For a class Foo, should its test class be called FooTest or FooTests?
...
6
votes
5answers
498 views
6
votes
2answers
440 views
Multithreaded log test
I'm writng a logger extension that allows multiple threads to log a process and then dump that log to the main log in one atomic operation. The point of it is to make the logs easier to read when many ...