Questions tagged [testability]

49 questions
2
votes
1 answer

What's the right way, for testability, to add functionality to a ComboBox?

The desired functionality of the 'enhanced' combo box is a quick find method. Each item in the combobox has a ToString() method, such that they can be displayed in the drop down list. On clicking an item in the drop down list, the combobox's…
Paul Smith
  • 1,044
  • 2
  • 13
  • 29
2
votes
2 answers

How would you test this function?

Let's say we have a function that converts an image to another format using terminal program convert. Here's the code: def convert_image(src, dest=None, extension='jpg', quality=100): # Create default destination - same path just different…
user2073343
  • 473
  • 1
  • 5
  • 13
2
votes
1 answer

Rewriting OS-query method to become testable

I'm going through our application's unit tests and improving/adding more of them. I'm quite (no, very) novice in unit testing/test-driven development and I found the following method that I wanted to test. I'm stuck, and my question is if there's a…
Amadeus Hein
  • 706
  • 1
  • 4
  • 12
2
votes
4 answers

Is it ok to use #if debug directive in C#?

We have a class a class that looks something like the following: public class Processor { //set timeout in seconds private const int TIMEOUT = 600; public void Process() { //DO SOMETHING HERE //CHECK TO SEE IF…
LJM
  • 6,284
  • 7
  • 28
  • 30
2
votes
2 answers

What is the impact on testability for an associations passed as parameters to a class?

I am working on an OO design problem. I'll try to focus on the part I am confused about and explain it in text rather than providing code. I have a class called SalesPolicy that contains a List of TaxPolicy. TaxPolicy is an abstract class that…
Chetan Kinger
  • 15,069
  • 6
  • 45
  • 82
2
votes
3 answers

How do you inject wcf client dependencies in a ViewModel and keep it testable?

TL;DR: What is a good and testable way to implement the dependency between the ViewModels and the WCF services in a MVVM client? Please read the rest of the question for more details about the problems I encountered while trying to do this: I am…
stralsi
  • 988
  • 1
  • 10
  • 17
2
votes
2 answers

Parser for C# code to evaluate testability?

I'm trying to write a program that will allow me to give it a collection of C# code files and analyze them for testability problems. I'm starting out with just the 4 provided in the preceding link. The end goal is to create a report of all the…
tmesser
  • 7,558
  • 2
  • 26
  • 38
1
vote
1 answer

Can I write any meaningful unit test in this scenario?

I have this entity - public class MerchantConfig { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private Long merchantId; private String configKey; private String configValue; .. } It stores…
Sandeepan Nath
  • 9,966
  • 17
  • 86
  • 144
1
vote
1 answer

Combining testable code with static method dispatch in swift

I've been reading a lot about Swift's runtime lately, and became more and more interested in optimising my code using static method dispatch. This happens with the following methods: struct methods final class methods, i.e. declared with the final…
Yotam
  • 9,789
  • 13
  • 47
  • 68
1
vote
2 answers

How to test Controller Action that uses JSON string from Request.Form?

I have an Action that gets JSON data from Request.Form[0] and has calls into domain objects. I am testing this method, but it seems impossible to set Request.Form. I could extract the method to another that takes the string it returns, but that…
StuperUser
  • 10,555
  • 13
  • 78
  • 137
1
vote
2 answers

What is the correct way here to modify/refactor product code to support integration testing?

Given below is my product code in essence and in a simplified representation. This one is like an algorithm for completing a workflow. Each of the steps(private methods) result in changes to a record in the database. Even the external tool…
Legolas21
  • 689
  • 5
  • 6
1
vote
4 answers

Testable design

I have a java class which has a static member created using Facade (Singleton). Class A implements InterfaceA { private static DataStore db = DataStoreFacade.getInstance("BDB"); //singleton instance public void save(final String key, final…
rjoshi
  • 1,645
  • 1
  • 20
  • 31
1
vote
6 answers

Constructor Injection, design for testability

I have this code (you probably can ignore that it is Swing code), but I usually end up with too many arguments in my constructor. Should I use model bean class and then pass that object in the constructor? public BrowserFrame(final JTextField url,…
Berlin Brown
  • 11,504
  • 37
  • 135
  • 203
1
vote
4 answers

Creating testable code

I have a file - in a large legacy codebase - containing methods that access databases. No classes are used, just a header file with the method declarations, and the source file with the implementation. I want to override these methods to eliminate…
LK__
  • 6,515
  • 5
  • 34
  • 53
1
vote
1 answer

Example of Difficulties when Testing Static Classes (C#)

I'm looking for an example to illustrate difficulties when testing a static class vs. instance class. Can someone provide one?
notlkk
  • 1,231
  • 2
  • 23
  • 40