Questions tagged [testability]

49 questions
0
votes
2 answers

How to abstract Linq2SQL for testability

I'm working on a project that uses Linq2SQL for data access. The project is made up of an ASP.NET MVC application and 8 class libraries. Most of the class libraries have their own L2S data classes. As part of the work I'm doing, I'm trying to get…
Greg B
  • 14,597
  • 18
  • 87
  • 141
0
votes
2 answers

Building a more testable session manager

I'm working on a set of components (that will hopefully become a full framework) and am currently working on one to provide an abstraction of PHP sessions. I'm trying to make the code as testable as possible, but a session class, by definition, is…
GordonM
  • 31,179
  • 15
  • 87
  • 129
0
votes
2 answers

Correct design of classes built for testability using constructor injection

Say I have these 3 layers of my code: 1. Database layer (ORM) 2. BusinessLogic 3. Application Now, I write my code as follows: Database layer: This mainly has CURD operations over database. class MyDatabaseLayer { public int findValue(int k) { …
zengr
  • 38,346
  • 37
  • 130
  • 192
0
votes
1 answer

In C#, what is the best way handle dependency inject a class which consumes multiple interfaces?

I have a class which consumes Renci.SshNet's SftpClient which implements BaseClient, ISftpClient. So, my constructor looks like: public CollendaSftpClient( CollendaCsvWriter collendaCsvWriter, CollendaSftpConfig…
0
votes
0 answers

Are there any good inter-method / inter-class complexity metrics?

A common advice on method/function length is to write small methods to increase both readability and testability. These are measured, for example, by cyclomatic and cognitive complexity metrics. Similar metrics apply to classes, or in general,…
0
votes
1 answer

How we can achieve writing reusable and modular code

How we can achieve writing reusable and modular code in an Enterprise code. What are the basics to get started
0
votes
1 answer

stability test of ARDL model in R

I would like to estimate an ARDL model with R according to the following procedure: Econometrics Beat: Dave Giles' Blog: ARDL Models - Part II - Bounds Tests (this blog's author uses EViews) Here is my ARDL model in R: Step1 <- lm(dlX ~…
Noorma
  • 1
0
votes
1 answer

Are there exceptions to no code in view model?

The general rule of thumb is that there should be no android specific code in view models to allow for easy testing. I need to pass a bundle with lots of metadata to the view model to filter and then return to the view. The logic is pretty dense,…
Android Ninja
  • 811
  • 1
  • 6
  • 9
0
votes
1 answer

Mocking locally created objects in java using Mockito2

I am writing module tests for a project using testng and Mockito2. I want to mock a few methods which make outbound requests. Now, the object to mock is created locally within another object's method. So, if I have say, 4 classes, A, B, C and D,…
0
votes
1 answer

whats wrong with a simple IOC container class?

last day I implemented a simple class to serve as IOC container (not much like that) in one of my playground projects and some pro guy told me that is going to have some problem when testing the code (too vein to share what exactly is the problem…
0
votes
1 answer

How to create a class with a list of elements from another class without breaking the dependency injection rule?

I have class that has several fields. public class Foo { int firstCoef; int secondCoef; public Foo(String args){ this.firstCoef=Integer.parseInt(args[0]); this.secondCoef=Integer.parseInt(args[1]); } } The arguments are assigned this way…
0
votes
1 answer

Testing fails to import sub dependency - @testable import SubModule - Use of undeclared type 'InternalSubModuleType'

I have a unit test that needs to access internal methods/properties on a module imported by my application target. E.g. SubModule.swift public class SubModuleType { ... internal let value: InternalSubModuleType …
Awesome-o
  • 2,002
  • 1
  • 26
  • 38
0
votes
1 answer

Console.Writeline in class method. Better Design

I am writing a simple console application and i want to be able to print to the screen. public class Car{ public void Drive(){ //Here I want to print that the car is driving } } I could just use Console.Writline() in my Drive()…
flexxxit
  • 2,440
  • 5
  • 42
  • 69
0
votes
1 answer

Should MVVM Locator invoke any registered ViewModel Funcitons?

Assume that there is WPF application which uses MVVM light toolkit. Good example of this toolkit is Locator. It is great it contains SimpleIoC which enables us to register Services and be Interface Driven. Sometimes Locator constructor can really…
komizo
  • 1,052
  • 14
  • 21
0
votes
1 answer

How would you test these functions?

I am novice with testing. When I develop my app, I use Robotium in order to test my apps, but now, I would like test some functions that are members of my Util class. For example: public static boolean internetConnection(Context context) { …
juanjo
  • 87
  • 1
  • 8