unit-testing

How can i write unit test for Gridview_RowCommand event?

I think question is itself explanatory. I am wondering how it is possible to write NUnit tests for such events. If you go deeper, it looks like using ASP.NET is not appropriate for writing unit tests. Thoughts please .. Edit The idea of this question is, if you have a grid view in your page and let's say you have gridview.rowcommand ev...

CodeCoverage vs ExpectedException

I've got several unittests of this pattern: [TestMethod ()] [ExpectedException (typeof (ArgumentNullException))] public void DoStuffTest_Exception () { var foo = new Foo (); Foo.DoStuff (null); } It turns out that code coverage markes the throwing line as half-run, so I get 1 block of uncovered code each time. After thinking ...

How to write a simple Silverlight unit test?

I'm looking to create some Silverlight unit tests. I've started by downloading the Silverlight Toolkit and looking at the unit tests there which are all built on the Silverlight Unit Testing Framework. However it seems that the test class structure is quite complex in the source and I don't want to re-write the test classes defined in t...

Should a unit-test method exceed 200 lines?

Is it too bad to write a really long (more than 200 lines) test method? Or should I break it up into smaller-methods? ...

Build Maven Project Without Running Unit Tests

How do you build a Maven project without running unit tests? Currently restructuring some code I have for a Servlet and would like to try it out in my web browser (which means running mvn install to get the .war to upload to Tomcat). I'm fully aware my UNIT test are failing and I'm fine with that because I will fix it once I have the co...

Unit testing a class with no return value?

Hello, I didn't find much in tutorials on this specific question.. So I have a class called 'Job' which has public ctors and a single public Run() function. Everything in the class is private and encapsulated in the class. (You may remember an older post here on this http://stackoverflow.com/questions/1590953/testing-only-the-public-me...

How to log output in the Silverlight Unit Testing Framework?

I would like to output test data when running test with the Silverlight Unit Testing Framework. I could go around it by creating some element and writing it on that however this feels like a hacked way. Is there any framework supported way of writing output during testing? ...

Mocking System.Drawing.Image with Moq

How would I go about mocking an Image with Moq? It has no constructors (is always generated from factory methods). Basically I want to do something like this... var image = new Mock<Image>(); image.Setup(i=>i.Save(someStream,ImageFormat.Jpeg); var testableObject = new ObjectUnderTest(image.Object); testableObject.MethodBeingTested();...

Automated Web Application Testing Framework

What is a good web application testing framework that I can use for a fairly large JavaEE based app? I am currently using Canoo Webtest, but we are running into issues with jQuery. I have tried upgrading the htmlunit to the current version, but that causes even more strange errors to occur. I am looking to see what other automated web ...

Tools/Modules to generate advanced reports from unittest.TestResult?

Hello folks! I am not satisfied by the text-formatting we use at my company for our unittest outputs, because it does not allow me to see, say, that a Test NEVER ever passed, or that a specific Test passed for the first time during that testRun. The current output does not allow me to have a clear view of the situation: All tests: 4***...

How to programmatically generate a window.event using Javascript?

Hi all: I am currently unit testing some javascript, where it handles an event raised by clicking on a certain item in the window. Below is a snipet of the code: function someFunction() { var evt = window.event ? window.event : event; if (evt == null) { return; } var nodeElement = evt.srcElement; if (nodeElement =...

problem of testing file worker in java

Hi I have a question which is described below: What problems would arise for testing a Java class which counts number of words in a file? The function's signature is below: public int wordCount(String filename) Well, this is a junit testing question. If you know the problem, what is the solution of that? ...

Xcode 3.1.3 problems unit-testing a plug-in

Following Chris Hanson's blogs and Apple's Automated Unit Testing with Xcode 3 and Objective-C I have started implementing unit tests for my projects. However, I use a lot of plug-ins (loadable bundles) and I can't quite figure out how to test them. I figured I would use the approach Chris Hanson described for testing frameworks. I star...

Problem running scripts against SQL Server

We have some scripts that we run as part of our unit tests. This worked fine until today. We have tried running scripts with both windows and sql authentication. We have no problems logging in using sql manager Anybody have any ideas why we get the following error: Shared Memory Provider: No process is on the other end of the pip...

Unit tests failing on TFS2010 Beta 2 written in VS2008

I've just setup TFS 2010 Beta 2 on our server and it's running fine. I've checked-in my solution which is written in Visual Studio 2008 SP1, with a main Class project and Unit test project. Source control is working fine with the forward compatibility patch for VS 2008 Team explorer to work with TFS 2010. The unit tests are written usin...

Eat, Sleep and Breathe Unit Testing/TDD/BDD

I do write unit tests while writing APIs and core functionalities. But I want to be the cool fanboy who eats, sleeps and breathes TDD and BDD. What's the best way to get started with TDD/BDD the right way? Any books, resources, frameworks, best practices? My environment is Java backend with Grails frontend, integrated with several exter...

How to test named_scopes and search methods?

When I learned about proxy_options I started using it to test all my named scopes. But then I found myself simply copying the conditions hash straight from the model, so it wasn't really testing the correctness of the results: po = {:conditions => "foo.created_at <= '#{Time.now.beginning_of_week}'"} assert_equal po, Foo.created_this...

Expecting an exception in a test but wanting to verify dispose is called anyway.

I'm unit testing a demo application, which is a POP3 client. The POP3 client implements IDisposable, so I'm trying to test a 'using' cycle. (I'm using nunit 2.5.2 and Moq 4.0) /// <summary> /// Unsuccesfull construct dispose cycle, no ILogger object given. /// Expecting ArgumentNullException. Expecting TcpClient dispose t...

where should I put my test code for my class?

So I've written a class and I have the code to test it, but where should I put that code? I could make a static method Test() for the class, but that doesn't need to be there during production and clutters up the class declaration. A bit of searching told me to put the test code in a separate project, but what exactly would the format of...

Reading from web.config while running Pex explorations

I've just started using Pex to generate parameterized unit-tests for my project. However, when I let Pex run its explorations, my code crashes because it cannot read from the web.config (ConfigurationSettings.AppSettings has zero elements to be more precise). The working-directory during the explorations is: "C:\Program Files (x86)\Micro...