unit-testing

Testing if Stored Procs "Parse"/"Compile" from code

Hi guys I am looking at doing some automated unit testing and I was wondering if you know of any way that one can "Parse"/"Compile" a stored proc(s) from code (i.e. from within .net). The case I am trying to catch is if someone makes a change to a table (i.e. removes a column) and that breaks a stored proc somewhere that they don't kn...

How does unit testing improve productivity?

I'm currently looking for ways to improve the productivity of our team. I've read in a number of places that unit testing can be used to improve productivity. I can imagine writing unit tests now can be helpful in the future, but does it help in the short term too? Because I don't understand how writing more code (=more potential bugs) c...

Are there any .NET web automation frameworks that support headless test execution?

Similar to htmlunit, but for use with C#. I've seen that you can use htmlunit with .NET via IKVM, but I'd like a native solution if at all possible. The aim is to add UI tests to our existing (xUnit.net) tests being run on the CI server. I'd like to be able to run UI tests in memory (since I don't want to be opening browser instances on...

Are really great programmers known to use unit testing?

I was wondering if really great programmers (Knuth, Kernighan, Torvalds, etc) are advocates of extensive unit testing. I can imagine large projects they've worked on adding them to deal with collaboration scaling issues, but did, say, Knuth use unit tests in TeX? And this doesn't weigh on my decision to use them, it's just a matter of cu...

Test class constructors not executing when running an xUnit Theory individually?

Toy example code: public abstract class testBase { public testBase() { //Some common test setup code, which will initialize ManagerClass } } public class someTests: testBase { public someTests() { //someTests-specific constructor code. } [Theory] [PropertyData("MyTestData")] public void test1(Foo foo) { ...

Creating mock Objects in PHP unit

Hi, I've searched but can't quite find what I'm looking for and the manual isn't much help in this respect. I'm fairly new to unit testing, so not sure if I'm on the right track at all. Anyway, onto the question. I have a class: <?php class testClass { public function doSomething($array_of_stuff) { return Anothe...

Delphi & unit testing: Include tested source in project, or just use it?

I have a project group with the main project and a test project. When writing unit tests for a class in the main project, do you include the source file in the test project, or do you put the path to it in the search path? Why do you do one over the other? Are there any best practices on this? UPDATE: It looks like including is the p...

Preferred unit testing isolation framework for .net

I have used the RhinoMocks product for quite some time and have been quite happy with the product - never had a reason to look elsewhere really. I was recently asked by the good folks at TypeMock to give their product a whirl and was wondering what other developers opinions are about Typemock Isolator. Are there any other isolation/moc...

Unit tests on MVC validation

How can I test that my controller action is putting the correct errors in the ModelState when validating an entity, when I'm using DataAnnotation validation in MVC 2 Preview 1? Some code to illustrate. First, the action: [HttpPost] public ActionResult Index(BlogPost b) { if(ModelState.IsValid) { ...

Visual studio project directory

Hi all, I'm writing a unit test for file uploading feature of my web application. I mocked a test file, and save it in the "Test files" subdirectory of the directory that my test project resident in. As I don't want to hard coded the file path. How can I know the directory of my project by code? I used @"..\Test files\test1.xml", but i...

django unit testing and global fixtures

I'm working on a web project in Django, and I'm using the python unittest framework. For every app I have some fixtures. This means, that every app has some identical tables in fixtures. I would like to share fixtures between apps and testcases, because otherwise if I change a model, I will have to change all json fixtures where this con...

Unit testing style question: should the creation and deletion of data be in the same method?

I am writing unit tests for a PHP class that maintains users in a database. I now want to test if creating a user works, but also if deleting a user works. I see multiple possibilities to do that: I only write one method that creates a user and deletes it afterwards I write two methods. The first one creates the user, saves it's ID. Th...

Does anyone know of a tool that will auto-generate Unit Test stubs?

Hello, I am writing a winforms application and eventually I would like to write unit test for this application from the DAL, and Biz Objects layers etc. Does someone know of a FREE tool that can recieve the path to an assembly and then output unit test stubs with matching signatures for the assembly. Any configurable options like "pub...

When exactly mock objects are to be used during unit testing rathern than using stubs?

In my experience anything that can be achieved using mock objects, could be achieved using stubs. Are there any scenarios, where stubs cannot be used and mock objects serves well. ...

Unittesting extension methods

Our team has just started unittesting and mocking, and we have run into some discussion considering extension methods. The question is what is a good approach to testing classes, that make use of extension methods. I.e. we have an Enum like this.. public enum State { [LangID(2817)] Draft = 0, [LangID(2832)] Booked = 1, ...

Is unit testing a bad idea during beta/prototyping?

A new project we began introduced a lot of new technologies we weren't so familiar with, and an architecture that we don't have a lot of practice in. In other words, the interfaces and interactions between service classes etc of what we're building are fairly volatile, even more so due to internal and customer feedback. Though I've alway...

Using Selenium to Test jQuery element data()?

Is it possible to use selenium to test whether a jQuery data() is set on an element? In my app, the user enters information about several orders. Each order gets appended to an overview table so they can see their progress as they're going. In addition to the visible order information, we store some additional information that we need...

Testing JavaScript code without recreating markup?

I want to test the JavaScript code in our web app. We are using the jQuery library and .Net MVC. I've looked at these answers, and jqUnit looked nice, so I tried it, just to realize that I'll have to pretty much recreate all markup for every page I want to test. Am I missing something? Are there any alternative approaches for testing J...

DisconnectedContext Error while running Unit Test project in VS 2008

I have a unit test project inside my solution. I keep adding new unit tests and modifying old ones. Some days ago, a message box keeps appearing when running my unit test project. The message box say: DisconnectedContext was detected Message: Context 0x2aae50' is disconnected. Releasing the interfaces from the current context (cont...

Import data for visual studio unit tests

How can I use an external data file in my Visual Studio unit tests? If I try to just include it in the test project and set Copy To Output Directory to true, it still can't be found. What I have is: [TestMethod] public void DoMyTest() { using (StreamReader rdr = new StreamReader("MyTestData.txt")) { blahblah } } Howev...