unit-testing

Using RSpec, how to verify from tags and link tags in view pages?

In view pages, people use form tag helpers and link helpers etc. If I then rename a controller, or a action, my view pages may break. How can I unit test view related tags for this kind of a breakage? ...

Where to keep static fixtures (files) in Java project?

I'm testing a number of classes which manipulate files on disc. I created a number of "mocked" files which I will pass to these classes. The question is where in my directory tree I should save them? I'm using Maven. ...

How to test with Python's unittest that a warning has been thrown?

Hi, I have a following function in Python and I want to test with unittest that if the function gets 0 as argument, it throws a warning. I already tried assertRaises, but since I don't raise the warning, that doesn't work. def isZero( i): if i != 0: print "OK" else: warning = Warning( "the input is 0!...

Select selenium element by name with parantheses?

I have the following input element: <input name='selected(1234)' type="checkbox" /> When I record, I get this: Command: click Target: selected(1234) This doesn't find the element, and neither does Target: name=selected(1234) My assumption is that the parentheses are somehow messing with the lookup. What's the proper way to do this...

Code coverage tools for C

I am using CuTest for unit testing and would like to get information about code coverage. Are there any code coverage tools available for C? Thanks ...

How can I create and use a partial stub (in MoQ) without being tied to the concrete implimentation?

I have code that uses MoQ to create a partial stub. I'd prefer to interact with the interface instead of the concrete implementation so that I won't have to modify the unit test if I have a different implementation of the interface. So for example, I have a factory method such as: private Mock<ISomeInterface> ISomeInterfaceStubFactory...

What documentation (, links and advices) could you offer me to create a testing library ?

Hi everyone, I'm thinking of designing my own Test library (framework) ->in c++ I am wondering if some of you have already designed there own (and what good advices, documentation they could offer me), decided to not do that (and why), What critics (and argue) you have against differents existing testing frameworks. I want to no more a...

junit 4 testing with spring 3.0 and Hibernate 3 in Eclipse - LazyInitializationException

I'm getting a LazyInitializationException trying to test my DAO methods using the tool stack defined in the title. My understanding is that my test must be running outside the hibernate session, or it has been closed before I try to read children objects from my DAO. From reading the documentation, I understood that using the @Transact...

How can I build a googletest unit test using the gtest_main library with Jam?

I am trying to build a googletest unit test for a proof of concept as a new unit testing framework that we could possibly use. In googletest, there are two ways to write a unit test: with a main, or without a main. If you do not define a main, you can link in the gtest_main library, which includes a main() function for you, saving you ...

Android: How do I reset/clear application preferences during unit testing?

I want to start with a consistent test environment so I need to reset/clear my preferences. Here's the SetUp for test I have so far. It's not reporting any errors, and my tests pass, but the preferences are not being cleared. I'm testing the "MainMenu" activity, but I temporarily switch to the OptionScreen activity (which extends Andr...

Can JUnit simulate OutOfMemoryErrors?

I have a method which tries to call an in-memory image converter, and if that fails, then tries to do the image conversion on disk. (The in-memory image converter will try to allocate a second copy of the image, so if the original is very large, we might not have sufficient memory for it.) public BufferedImage convert(BufferedImage img,...

Ruby Unit test - Instance variable declared in setUp takes value nil

Hello I have a trouble with Ruby unit testing, I'm new to it so some help would be lovely class TestItem < Test::Unit::TestCase def setUp @item=Item.new('Food','Burger',120) end def testGetType assert_equal(@item.getType,'Food') end end Here the value of instance variable @item takes nil when I declare it in setUp() and use it ...

NUnit AreEqual always returns false.

I'm sure I missing something simple here but I can't figure out why my NUnit object comparison test continues to fail. I have a simple object: public virtual int Id { get; private set; } public virtual string Description { get; set; } public virtual string Address { get; set; } public virtual string Ports { get; set; } ...

Testing for Exceptions using JUnit. Test fails even if the Exception is caught.

Hi, I am new to testing with JUnit and I need a hint on testing Exceptions. I have a simple method that throws an exception if it gets an empty input string: public SumarniVzorec( String sumarniVzorec) throws IOException { if (sumarniVzorec == "") { IOException emptyString = new IOException("The input...

C# .NET 4.0 Testing Framework?

If I'm not mistaken, NUnit is the de-facto standard for unit testing, but I've just downloaded it, wrote a simple test, and then apparently I have to fire up the GUI and load my .exe assembly, which simply failed. I tried editing C:\Program Files (x86)\NUnit 2.5.7\bin\net-2.0\nunit.exe.config As suggested in this question, but that...

SentTestCase doesn't highlight UnitTest failures as errors in code

I have setup UnitTests for some of the logic of my iphone app, I followed apple's guide for UnitTests in XCode, however when some of the assertions fail - instead of highlighting the place directly in code like a regular compilation error - XCode just displays the number of errors in the bottom-right corner and I have to look up the erro...

ASP.NET-MVC: Do Database Default Values Break The Spirit of Unit Testing?

Related Question My Question: In the key of ASP.NET-MVC - Do Database Default Values Break The Spirit of Unit Testing? ...

android - accessing test application assets

Hi, I've an XML file in the assets directory of my test application. I want to access this file from my suite method of the test class. ie., public static TestSuite suite(){ InputStream stream = // Some code which returns the asset } Any idea how I can do this? I tried with Resources.Resources.getSystem().getAssets() but no luck ...

How to test windows phone 7 class library?

Is there any way to test a Windows Phone 7 Class library? Usually (for WinForms or WPF applications) I create separate class library and add reference to nunit.framework.dll and to a class library which I want to test. Here, if I create new Windows Phone class library it doesn’t allow me to add reference to NUnit framework assembly. I...

Is Visual Studio 2010's unit testing feature usable for native C++ code?

It seems to be mainly tailored to .net code. ...