unit-testing

Private Accessor don't build when using MSBuild

My build server uses MSBuild to build my application. Our unit tests require access to some private members for testing, so we use the built in private accessors. Visual Studio has no problem with it, but when we push our code to the build server we get the error: MyTest.cs (96,13): errorCS0246: The type or namespace name 'My_Acc...

What numbers can you pass as verbosity in running Python Unit Test Suites?

The Python unittest framework has a concept of verbosity that I can't seem to find defined anywhere. For instance, I'm running test cases like this (like in the documentation): suite = unittest.TestLoader().loadTestsFromTestCase(MyAwesomeTest) unittest.TextTestRunner(verbosity=2).run(suite) The only number I've ever seen passed as ver...

Python unit test with base and sub class

I currently have a few unit tests which share a common set of tests. Here's an example: import unittest class BaseTest(unittest.TestCase): def testCommon(self): print 'Calling BaseTest:testCommon' value = 5 self.assertEquals(value, 5) class SubTest1(BaseTest): def testSub1(self): print 'Calli...

How do I link my executable to my test bundle when debugging test using otest?

I'm using kind of a hybrid of Chris Hanson's excellent Xcode unit testing guide. My program is a (command-line) application (which precludes using the executable itself to run the tests), but I need to be able to debug my unit tests. So what I have is as follows: Create test bundle and tests. Create new test target, set bundle loader ...

Test discovery tool for .NET

Is there a tool for automated test discovery for .NET. I am using the Visual Studio unit testing stuff and wanted functionality similar to Python Nose. I need to have a tool automatically discover all the unit test available and run for example the ones "marked" as unit and in different scenarios run the tests "marked" as Integration a...

Python 3 unittest simulate user input

How can I simulate user input in the middle of a function called by a unit test (Using python 3's unittest)? For example, I have a function foo() who's output I'm testing. In the foo() function, it asks for user input: x = input(msg) And the output is based on the input: print("input: {0}".format(x)) I would like my unit tes...

What is the equivalent of Java's default (package) access in C#?

What is the equivalent of Java's default (package) access in C#? Is there one? Is there anyway to restrict access to a particular namespace? The Problem: I'm trying to restrict access to certain methods to just my NUnit tests - in JUnit I would do this by making the methods package access and having the test in the same package but un...

Stop running tests on setup failures

We are using NUnit to run a large number of integration tests. All these tests share a base class, which as a test fixture setup method that preps the data needed for the rest of the tests. Is there any way to stop running tests if there is a failure in the test fixture setup? Right now it waits until all the tests fail with the same ...

Overloading failUnlessEqual in unittest.TestCase

Hi, I want to overload failUnlessEqual in unittest.TestCase so I created a new TestCase class: import unittest class MyTestCase(unittest.TestCase): def failUnlessEqual(self, first, second, msg=None): if msg: msg += ' Expected: %r - Received %r' % (first, second) unittest.TestCase.failUnlessEqual(self, f...

XML data for Unit testing

We are looking to run a large amount of data through some unit tests. We would like to define this in some sort of excel spreadsheet or XML document. Is there away to get the unit testing framework to load this data as input and expectations. I can foresee this having issues with exception catching. Any comments on this are appreciat...

How to force VS2008 C++ post-build events to execute?

For various C++ library projects in VS2008 I have a sibling project called <libraryname>-Test. This is an executable project that depends on the library and runs tests on it. The post-build configuration of the test project consists of simply: "$(TargetPath)" Visual Studio won't re-run the post-build step unless it actually does ...

Rhino Mocks - stub out something that returns IQueryable(Of T)

I work w/ Rhino Mocks 3.5 a lot but recently came across something I had never tried before. I want to stub out a service and setup the return value - simple stuff really The only issue is that now my service isn't returning IList, but instead IQueryable So when I try to do something like this - it blows up <TestMethod()> _ Publi...

What is the prototypical unit testing framework for non oo languages?

Every language that supports Object Orientation has a port of xUnit. What about for non-oo languages? Are there advantages, or different ways of doing things, and if so, is there a prototypical example (like xUnit is for OO languages)? ...

Can I repeat a unit test repeatedly over a collection in Visual Studio 2008?

I have a unit test where I run a method for every item in a collection (using a foreach). Currently I have an assert at the end of the foreach to test if the method returned the correct value. This works, but the result is the test fails when the method fails for the first time. No subsiquent items in the collection are tested. I would...

rails - how to grab fixture data from within tests

I've looked at the rails guide to testing but I can seem to get fixture data from inside my test. I have a fixture: one: pay_period: one employee: kent cpp: 50 ei: 40 tax: 100 vacation_pay: 30 Then I have a test as per below (where EmployeePayPeriod is a model) require 'test_helper' class EmployeePayPeriodTest < ActiveSu...

How do I test webservices?

I am a novice in web services. I am totally new to testing web services. A new project demands that I test the web services, and the customer is in favor of any open source tool. What is the approach to testing web services? Also Please suggest a tool(with minimal scripting) to test web services? ...

Should Python unittests be in a separate module?

Is there a consensus about the best place to put Python unittests? Should the unittests be included within the same module as the functionality being tested (executed when the module is run on its own (if __name__ == '__main__', etc.)), or is it better to include the unittests within different modules? Perhaps a combination of both app...

Visual studio NUnit integration

Hi, For some project templates (ASP.NET MVC, WPF MVVM app...), Visual Studio 2008 prompts the user if he wants to create a test project : However, in the list of test frameworks, only "Visual Studio Unit Test" is available. I'd like to be able to choose NUnit instead... Is this possible, and how ? I installed TestDriven.NET, but it ...

Is testing from inside an application via embedded scripting a good idea?

I'm working on a large GUI Program and even after years of development I still have not a single test case. I removed a lot of the needs by using Eiffel together with disciplined coding and Design By Contract. But sometimes I feel that having unit tests might help me. But whenever I try to write some down I soon run into the problem wi...

How do you unit test templating code?

For example, I have a piece of code that's generating a SQL*Loader control file from this template (using Python): template = """ LOAD DATA INFILE '%(file_path)s' APPEND INTO TABLE %(table_name)s FIELDS TERMINATED BY "%(delimiter)" OPTIONALLY ENCLOSED BY "" (\n%(column_specifications)s\n) """ There are only two ways that I can think o...