unit-testing

Rails Unit Test Issue with rake

Hey guys, I am working on writing tests for a rails 2.3.4 application and I am running into the following error when I try to run the tests 1) Failure: default_test(ReportTest) [rake (0.8.7) lib/rake/rake_test_loader.rb:5]: No tests were specified. This is what the only test file looks like: require File.dirname(__FILE__) + '/../test...

What testing frameworks are used for Rails?

I am new to rails, but not to ruby, and the book I am reading (Pragmatic Programmers Agile Dev. with Rails 4th Ed.) just introduced me to unit tests in Rails. The book showed me the default rails testing suite (a subclass of Test::Unit). In the Rails community, is this the main testing framework that is used, because I use RSpec when doi...

Unit Testing Vocabulary: "coverage"

I'm preparing some educational/training material with respect to Unit Testing, and want to double check some vocabulary. In an example I'm using the developer has tested a Facade for all possible inputs but hasn't tested the more granular units 'behind' it. Would one still say that the tests have "full coverage" - given they cover the ...

How to execute a SQL script to prepare DB before executing Unit Tests in Visual Studio

Hello, I have a lot of unit test that depend on a certain configuration of a database. I would like to execute a script every time I run the unit tests so the database is Ok and the tests do not fail due to wrong data at DB. I currently have a SQL script to put the right data at the DB. Is there a way of doing that from Visual Studio (...

Should I write unit tests as console apps first?

I'm debugging a set of WCF services. Initially, I created some unit tests, but since I'm using threading I often receive "Aborted" or "Stopped" tests without any clear explanation why (this is a known bug in Visual Studio). I found it extremely challenging to debug the services when I can't even read the log output, so I quickly wrote a...

Reporting on test scenarios for a non-technical audience ?

I have (jUnit) unit tests. My project manager would like a human-friendly list of test cases and scenarios (think: a spreadsheet or report for general distribution to a less technical audience). What is an effective way to bridge this gap? ...

Unit testing of private methods

I am in the process of writing of writing some unit tests. In particular I want to test some private methods. So far the I have come up with using. #define private public But I am not happy with this as it will destroy all encapsulation from the point of view of the unit test. What methods do you use to unit-test private methods. ...

IList<something> constructor parameter and AutoFixture

Using autofixture, I'm trying to construct anonymous instance of Project: _f=new Fixture().Customize(new AutoMoqCustomization()); _p=_f.CreateAnonymous<Project>(); This fails, cause Project public constructor demands IList<Partner> public Project(/*.....*/,IList<Partner> partners){ Guard.AgainstEmpty(partners); } Stack trace is...

TestNG: How to test for mandatory exceptions?

I'd like to write a TestNG test to make sure an exception is thrown under a specific condition, and fail the test if the exception is not thrown. Is there an easy way to do this without having to create an extra boolean variable? A related blog post on this subject: http://konigsberg.blogspot.com/2007/11/testng-and-expectedexceptions-iv...

phing and phpunit + bootstrap

How to run PHPUnit test suite with bootstrap file with phing? My app structure: application/ library/ tests/ application/ library/ bootstrap.php phpunit.xml build.xml phpunit.xml: <phpunit bootstrap="./bootstrap.php" colors="true"> <testsuite name="Application Test Suite"> <directory>./</directory> </testsuit...

How to unit test code that adds a string to a bit map

I'm trying to unit test some code that adds a string to a bitmap. The code works fine when the app is running. But I'm having trouble writing a unit test for it. This is the SUT: public byte[] AddStringToImage(byte[] image, string caption) { using(var mstream = new MemoryStream(image)) using (var bmp = new Bitmap(mstream)) ...

Unity unit testing - registering types

I'm having a difficult time registering my types for Unity 2 in my unit tests. Here's a snippet of the class under test: public class SomeService : ISomeService { private int SomeVar { get; set; } [Dependency] public ISessionManager SessionManager { get; set; } public SomeService() { SomeVar = SessionManag...

Why does the following test fail using Mbunit and Rhino mocks?

I am playing around with MbUnit and Rhino Mocks and made a simple test. It may be poorly designed code, but I am more focused on just seeing if I can get the test to pass. Basically, When the engine light of a car is on, the car should an oil change. Here is code: public interface ICar { bool EngineLight { get; set; } void Get...

How do you assert a generic method was called with Rhino Mocks?

I have the following test to verify that my repository is calling it's respective session (I've rewritten it to highlight the actual problem): [Test] public void Why_Does_This_Fail() { var objectUnderTest = new SomeGenericsProblem(); var fakeSession = MockRepository.GenerateMock<ISession>(); fakeSession....

How do I mock Perl's built-in backticks operator?

I'd like to unit test a Perl program of mine that is using backticks. Is there a way to mock the backticks so that they would do something different from executing the external command? Another question shows what I need, but in Ruby. Unfortunately, I cannot choose to use Ruby for this project, nor do I want to avoid the backticks. ...

Does Microsoft Windows SDK for Windows 7 include library for MS unit testing?

After I installed the SDK on our new Windows 7 build machine, I got errors from our unit test project: DsHelperTest.cs(2,17): error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) SKMTest.cs(3,17): error CS0234: The type or namespace name 'VisualStudi...

MbUnit vs Nunit

I read that MbUnit is Nunit on steroids, but I don't see why. From what I have read on here, I here that Nunit is more popular over MbUnit. One of the main reasons is because it has a fluent interface. Is this the only reason? Why should I prefer MbUnit over Nunit, or vice-versa? Thanks! ...

How to use boost::unit_test?

I'm trying to learn how to test programs so I tried Boost. I've started reading it and here I've met this line: Now I can compile it and link with the unit test framework. From where and how am I suppose to get unit test framework? And what it is? I just do not know what to eat it with. Could someone please provide some steps how to ...

Can I run a single unit test from the command line for a Grails project?

I've been running my Grails unit tests by typing grails test-app :unit, which runs all unit tests. Is there a way to specify a single test? Edit: So far, everyone is basically saying the same thing, but when I do that, no tests are run. Any more thoughts? Conclusion: OK, I was using the name of the test class, rather than the name ...

Reflect Over List of Controllers

Hi - I'm a bit new to reflection in c#. I'm trying to generate a list of all controllers in order to test whether or not they are decorated with a specific actionfilter. When writing unit tests, how do you access the tested assembly? This does not seem to work: var myAssembly = System.Reflection.Assembly.GetExecutingAssembly(); ...