unit-testing

Unit testing a value object

Is it necessary to unit test a value object, and how would you go about it? Take for instance this object: public class TeamProfile { public string Name { get; set; } public int Wins { get; set; } public int Losses { get; set; } public int Draws { get; set; } } ...

Unit testing: More Actions than Expected after calling addAction Method

Here is my class: class ManagementReview(object): """Class describing ManagementReview Object. """ # Class attributes id = 0 Title = 'New Management Review Object' fiscal_year = '' region = '' review_date = '' date_completed = '' prepared_by = '' __goals = [] # List of <ManagementReviewGoals...

When having to do a design change, should I change the already working tests first and only then try to run the new one?

I have a bunch of tests that assume that my Tetris class is composed by a Board class. I now feel that instead of having a Board inside of that Tetris class, what I will want is to have a Board inside a BoardEngine class that is inside the Tetris class. That is what this test is asking for: [TestMethod] public void Start_Game_An...

GPL and test cases?

Hi Stack Overflow - I am developing a pure-Python module as a drop-in replacement for a C extension module. This C extension module is GPL'd and has unit tests written in Python. If I am developing open-source software under the MIT, am I able to re-use these test cases in my project? ...

Selenium, automated frontend testing on different OS

My complete working environment is Linux based (Ubuntu for desktop and server). I use Hudson and Selenium to execute tests on my EE6/ZK web application with any browser available for Ubuntu. But how would I test my application with IE (Windows) without setting up a Selenium server in Windows. Thought I could run Windows in a VMWare or V...

Should I Unit Test Data Access Layer? Is this a good practice and how to do it?

If I'm having Data Access Layer (nHibernate) for example a class called UserProvider and a Business Logic class UserBl, should I both test their methods SaveUser or GetUserById, or any other public method in DA layer which is called from BL layer. Is this a redundancy or a common practice to do? Is it common to unit test DA layer, or th...

Problem with ArgumentCaptor and consecutive call to same methods (bug or feature?)

Hello, I'm having a problem with ArgumentCaptor not being able to record the arguments when calling the same method a number of times. Basically this does not seem to work: List<Dummy> mList = mock(List.class); Dummy dummy = new Dummy(); when(mList.get(anyInt())).thenReturn(dummy); Dummy d = mList.get(12); d.setName("John"); mList....

Automated testing of privileged operations

How do you unit/integration test code that requires a different privilege level than exists in your continuous integration environment? In my non-root, CCRB-driven build environment, I've got some utility functions that assume privileges that don't hold in my automated build environment: either root privileges or special accounts and g...

Mocking library/framework that works best in Android?

I'm developing Android application using third party libraries (Twitter4j). I want to be able mock those objects (also objects created by me) in JUnit and functional tests. Do you have any good experiences using some mocking libraries and you can recommend them? ...

How to mock PreferenceManager in Android?

I've written a class that is using Context, third party library and SharedPreferences from PreferenceManager. It's possible to mock Context, third party library can be mocked using some mocking framework, but what to do with PreferenceManager? I have two methods: public void saveString(ThirdPartyObject obj) { SharedPrefer...

Why can I no longer run unit tests from Resharper's test runner?

Things were running fine. Who knows what changed, but now I end up with: Unit Test Runner failed to load test assembly: JetBrains.Resharper.TaskRunnerFramework.TaskException:Exception of type 'Microsoft.VisualStudio.TestTools.CommandLine.CommandLineParameterException' was thrown. Any suggestions? ...

How to ignore generated code from code coverage data

I am using Visual Studio 2010 and would like to exclude the generated service reference code from my code coverage statistics. I found an article pre 2010 that mentions using DebuggerNonUserCode and DebuggerHidden attributes. I have tried this an it works as advertised. DebuggerNonUserCode is set at the class level, but with 50+ classe...

Controller tests with authlogic expecting user_sessions table

I'm using Authlogic (along with Authlogic RPX) in a new Rails 3 application (beta4 , just upgraded to RC). I cannot get any of my functional tests to pass. Anytime I try to run even the most rudimentary test, I end up with this error: 4) Error: test_the_truth(UsersControllerTest): ActiveRecord::StatementInvalid: SQLite3::SQ...

Is Unit Testing worth the effort, in a large and old (5yr) codebase?

I've just joined a team which has been working in a main-always mode for the last 5 yrs (java, maven based project). Consequently plans to leverage unit testing have always been in the pipeline, never materialising (so far). A Great dev team has ensured that code quality is generally good, and there aren't structural code issues, but the...

NUnit Repeat attribute

Is it possible to use Repeat attribute in NUnit but failure of one repetition not to cause failure of remaining ones? So, if 3rd repetition is failed, i would like that NUnit still executes 4th, 5th, a so on... ...

Multiple cleanup actions on VS2008 Unit Testing

Hello guys, The questions is pretty straightforward and I need to know how to create multiple cleanup tests. I have some tests, and each test creates a different file. I would like to bind a cleanup action to each, so I can delete the specified files for each test. eg: [TestMethod] public void TestMethodA() { // do stuff } [TestMeth...

Does code contracts really help unit testing?

I have fair amount of knowledge on unit testing. I have been trying to read about code contracts. Does it really help unit testing? Is it over-rated especially when we talk about code-contract helping to do unit testing. I am specifically referring to contracts in .net 4.0. I use nunit for unit testing. ...

tdd with non-trivial algorithms

Hi there, In these days I'm coding some data structures in Java. Many of them (if not all) offer a very simple interface (add, contains, delete) but under the hood there are non-trivial algorithms. How can I use the tdd technique in such a situation? I think that the problem is that tdd (and in general unit testing) is about testing t...

ASP.net/C#: How compile classes in App_Code so that can be run from command line for unit testing?

I have several class files in App_Code in an ASP.net website running in Microsoft Visual Studio 2005 Professional. In liu of using a full unit test suite I just want to somehow compile those project-wide classses into an .EXE so that I can nightly run unit tests on them. I do know how to create a separate C# library project consisting ...

Unit testing when developing a website?

After learning about TDD and unit testing, I'm really looking to write tests when I code, preferably before I code because I see the benefits coding in Python. I'm developing a website, and I'm trying to write tests according to the requirements, but its proving more difficult than expected. I can see the benefits of writing tests when ...