unit-testing

JS Unit Testing on NUnit/NAnt

Maybe you know the simplest way of unit testing javascript functions (not UI like Selenium or WatiN) which can be automated (I prefer using NUnit, eventually NAnt) ? I need to introduce an automated unit test for javascript functions on CruiseControl.NET (so with NUnit and NAnt) - but maybe there is other way ? Thanks, Dawid ...

How should I approach to fix a DNN web application?

Myself and my team is taking over a DNN web application done by a software development vendor. There are some issues like 1. redundant non-standard data / API to access to tab and configuration of a module, and 2. some other architecture related issues. My goal is to remove things we don't need and steer the application back to DNN be...

How can I use Rhino Mocks to inspect what values were passed to a method

hey guys I'm new to mocking, and I'm having a hard time solving an issue with UnitTesting. Say I have this code: public class myClass{ private IDoStuff _doer; public myClass(IDoStuff doer){ _doer = doer; } public void Go(SomeClass object){ //do some crazy stuff to the object _doer.DoStuff(o...

JUnit 4.8.1 / Maven trivial test not working

Hi Although I tried out all suggestions I found, I still can't get the most trivial JUnit test running. The error message basically repeats saying "junit.framework.AssertionFailedError: No tests found in project002.trivial.TestClassTest". You may inspect a snapshot of my IDE or download the zipped project. Here is my pom.xml: <projec...

Coded UI Test Builder does not appear with setup project in solution

I am using VS 2010, and I was able to create a Coded UI test successfully, once. I am trying to do the same, but the Test Builder Dialog box does not appear anymore. I found the following post: http://social.msdn.microsoft.com/Forums/en/vsautotest/thread/ff495f15-bb42-454d-88af-ae4d3bb4a075 This describes my problem somewhat. I do have...

Overriding method in ruby module for testing?

How do I override methods in a module? ...

Creating a test without methods

Is there a strick one-to-one correspondence with a test in VS and a method? In the end, it's just code, right? I'd love to run-time generate separate tests based on data input. I realize I could just have one test that loops through my data and performs all of the desired operations, but I'd rather have each item be represented by an i...

Translating Rspec tests to Shoulda

Hello, I have a pre-written Rails app for handling subscription based payments that is currently covered with an Rspec test suite. I'm trying to merge it into a Rails app that is covered using the Shoulda test suite. I'd really hate to have to rewrite all the tests into Shoulda compatible matchers manually, so I was wondering if there m...

Mocha expectation on association build call failing

I have this example: # GET New context "on get to new" do it "should assign cardset" do @profile.cardsets.expects(:build).once.returns(Factory.stub(:cardset)) get :new assigns[:cardset].should_not be_nil end end To test this method: # GET /cardsets/new def new @cardset = current_user.cardsets.build end I am trying...

Can I unit test a method that makes Sitecore context calls ?

I'm working on a web application that is built over Sitecore CMS. I was wondering if we could unit test for example a method that takes some data from Sitecore makes some processing with it and spits out a result. I would like to test all the logic within the method via a unit test. I pretty confused after searching the internet wide an...

how to unit test the CustomWebFormViewEngine.FindView(...) method with Mock controllerContext?

Want to unit test the following piece of code. can some one help me out? I saw many post that we can use different open source frameworks like Rhino mocks, moq etc. But I can't figure it out what exactly required to mock how the value should intilize while creating mock objects. my class is as follows. public class CustomWebFormViewEngi...

Asp.net Web Service Test Error

Hi. I'm just stuck within ASP.NET, I've created a Unit Test Class for test a blank Web Service (want to do TDD). When I try to run the Web Service, it supposed to run and fail, but it fail to execute, it says: The test adapter 'WebHostAdapter' threw an exception while running test 'EnrollmentWSConstructorTest'. The web site could not ...

Using Eclipse to create a new JUnit test case

I have a question about using Eclipse to write an additional JUnit test case for an existing Java application. There's a folder called "pass" which contains all of the pass tests. I create a new pass test by right clicking on the folder and going to New -> File. However, when I create the JUnit test case, the new test doesn't show up a...

Using httpcontext in unit test

I'm using C#4.0 and i need to unit test a service. The function inside the service returns a path similar to the variable i called expected, this is the path i'm expecting to get back. But when i run this test i'm getting the error that HttpContext.Current is NULL. What can i do to fix this issue so the test can be ran? [TestMethod] pub...

MSTest + MSBuild + Many test projects

I am responsible for maintaining the msbuild scripts for a large project. The solution contains about 90 projects each having their own test project. As part of the build process all test projects are agregated and mstest is called once: mstest /textcontainer:project1 /testcontainer:project2 ... This is no longer a viable solution as...

Moq to Rhino - fake partial repository

I got this really cool Moq method that fakes out my GetService, looks like this private Mock<IGetService<TEntity>> FakeGetServiceFactory<TEntity>(List<TEntity> fakeList) where TEntity : class, IPrimaryKey, new() { var mockGet = new Mock<IGetService<TEntity>>(); mockGet.Setup(mock => mock.GetAll()).Returns(fakeList); mockG...

Unit testing an ASP.NET 2.0 Web service application in VS 2005.

Hi, Most of the stuff I find about unit testing ASP.NET apps seems to be for VS 2010 / later versions of .NET / Visual studio in general. I can't really find the "Create unit tests" option in Visual studio 2005 at all. Can anyone point me to how I can go about Unit testing a .NET 2.0 app in VS 2005? Thanks, Teja. ...

Testing with varying system ini settings

Ok, so here's the issue I've run into. On some of our production systems, we have magic quotes gpc enabled. There's nothing I can do about that. So, I've built my request data handing classes to compensate: protected static function clean($var) { if (get_magic_quotes_gpc()) { if (is_array($var)) { foreach ($v...

Set Value of Private Static Field

I want to set the value of a private field using reflection for unit testing. Problem is, that field is static. Here's what I'm working from: /** * Use to set the value of a field you don't have access to, using reflection, for unit testing. * * Returns true/false for success/failure. * * @param p_instance an object t...

How do i test user input from the gets method in ruby?

Say I have the following method: #Create new guest object. Add it to array and save it to disc def new_guest printf "First name: " first_name = gets.chomp printf "Last name: " last_name = gets.chomp printf "Adress: " adress = gets.chomp printf "Phone:" phone = gets.chomp new_guest = Guest.new(first_...