Creating a new user with NUnit

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
MarkI
Ensign (ENS)
Ensign (ENS)
Posts: 17
Joined: Mon Jun 02, 2008 1:54 pm

Creating a new user with NUnit

Post by MarkI » Tue Sep 23, 2008 11:39 am

Hi,

I've added an NUnit project to our AbleCommerce solution. Right off the bat I'm running into issues trying to simply create a user. Has anyone tried this?

Here is what I am calling:

Code: Select all

//...
User user = UserDataSource.CreateUserInstance(Guid.NewGuid().ToString());
//...
In the file I am "using CommerceBuilder.Users;"

However, I am consistently getting the following error on the line above:

Code: Select all

"System.Configuration.ConfigurationErrorsException : Unable to open configSource file 'App_Data\ablecommerce.config'."
I have tried copying this file into the bin directory of NUnit's project, which is the typical thing to do for config files and NUnit, but with no luck.

Any help/suggestions/pointers is greatly welcome.

Thanks,

Mark

afm
Captain (CAPT)
Captain (CAPT)
Posts: 339
Joined: Thu Nov 03, 2005 11:52 pm
Location: Portland, OR
Contact:

Re: Creating a new user with NUnit

Post by afm » Tue Sep 23, 2008 2:00 pm

First try creating a directory called App_Data under bin (this is just a wild guess). If that does not work, then use FileMon to see where it is looking and then put the file there.
Andy Miller
Structured Solutions

Shipper 3 - High Velocity Shipment Processing

MarkI
Ensign (ENS)
Ensign (ENS)
Posts: 17
Joined: Mon Jun 02, 2008 1:54 pm

Re: Creating a new user with NUnit

Post by MarkI » Wed Oct 01, 2008 11:52 am

Thanks Andy,

Your post helped me solve it. I tried FileMon, but that has been replace by "Process Monitor" for use in Vista. Process Monitor helped me discover that it is looking for App_Data under bin\Debug.

For those who attempting using NUnit (which I highly recommend) with AbleCommcerce, the following line of code requires that both the ablecommerce.config and the database.config must be copied to <your nunit test project folder>/bin/Debug/App_Data.

Code: Select all

User user = UserDataSource.CreateUserInstance(Guid.NewGuid().ToString());
Thanks,

Mark
Last edited by MarkI on Thu Oct 02, 2008 9:44 am, edited 1 time in total.

afm
Captain (CAPT)
Captain (CAPT)
Posts: 339
Joined: Thu Nov 03, 2005 11:52 pm
Location: Portland, OR
Contact:

Re: Creating a new user with NUnit

Post by afm » Wed Oct 01, 2008 9:31 pm

Thanks Mark. That would be a handy tip for the wiki.
Andy Miller
Structured Solutions

Shipper 3 - High Velocity Shipment Processing

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Creating a new user with NUnit

Post by AbleMods » Wed Oct 01, 2008 10:32 pm

What's NUnit??
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
Shopping Cart Admin
AbleCommerce Admin
AbleCommerce Admin
Posts: 3055
Joined: Mon Dec 01, 2003 8:41 pm
Location: Vancouver, WA
Contact:

Re: Creating a new user with NUnit

Post by Shopping Cart Admin » Wed Oct 01, 2008 10:41 pm

Hello Joe,

Never heard of google :)

http://www.nunit.org/index.php

What Is NUnit?

NUnit is a unit-testing framework for all .Net languages. Initially ported from JUnit, the current production release, version 2.4, is the fifth major release of this xUnit based unit testing tool for Microsoft .NET. It is written entirely in C# and has been completely redesigned to take advantage of many .NET language features, for example custom attributes and other reflection related capabilities. NUnit brings xUnit to all .NET languages.
Thanks for your support

Shopping Cart Guru
AbleCommerce.com
Follow us on Facebook

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Creating a new user with NUnit

Post by AbleMods » Thu Oct 02, 2008 6:16 am

I don't really know what XUnit is any more than NUnit.

But I've recently learned about something called Google so I'll go see what it does on my own.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
Shopping Cart Admin
AbleCommerce Admin
AbleCommerce Admin
Posts: 3055
Joined: Mon Dec 01, 2003 8:41 pm
Location: Vancouver, WA
Contact:

Re: Creating a new user with NUnit

Post by Shopping Cart Admin » Thu Oct 02, 2008 9:35 am

Hello Joe,

I'd heard of if a number of times, but never checked into until this post.
Thanks for your support

Shopping Cart Guru
AbleCommerce.com
Follow us on Facebook

afm
Captain (CAPT)
Captain (CAPT)
Posts: 339
Joined: Thu Nov 03, 2005 11:52 pm
Location: Portland, OR
Contact:

Re: Creating a new user with NUnit

Post by afm » Thu Oct 02, 2008 2:39 pm

I've been using NUnit for a couple of years to automate regression testing (i.e. I can run the tests to make sure that my existing code still works the way they are supposed to after fixing a bug or adding a feature). It has become much more popular lately with the rise in test driven development (TDD), where you write the test first (i.e. The test defines what the feature is supposed to do, then you write the code. You know the code is "done" when the test passes.).

In TDD it is important that the tests--which define the features--are easy to write and clearly define the feature. For the most part, NUnit meets those requirements. For example,

Code: Select all

[Test]
public void New_Customer_Should_Have_Empty_Names()
{
    Customer customer = new Customer();
    Assert.AreEqual(customer.FirstName, string.Empty);
    Assert.AreEqual(customer.LastName, string.Empty);
}
Andy Miller
Structured Solutions

Shipper 3 - High Velocity Shipment Processing

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Creating a new user with NUnit

Post by AbleMods » Sun Oct 05, 2008 10:15 am

Does it automate (i.e. simulate) the user input?
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

afm
Captain (CAPT)
Captain (CAPT)
Posts: 339
Joined: Thu Nov 03, 2005 11:52 pm
Location: Portland, OR
Contact:

Re: Creating a new user with NUnit

Post by afm » Sun Oct 05, 2008 10:54 am

SolunarServices wrote:Does it automate (i.e. simulate) the user input?
Depends on how the app is written. For AC7, no. For that you need one of the GUI testing frameworks like Watir.

For apps that follow a strict model-view-controller architecture, raw user input is typically passed to the controller. And you can test the controller's behavior to user input using NUnit.

AC7 does some user input processing in the "view" (the webform or it's code-behind file). To test that you need to pretend to be an actual user clicking on buttons and entering text. That is what Watir does.
Andy Miller
Structured Solutions

Shipper 3 - High Velocity Shipment Processing

MarkI
Ensign (ENS)
Ensign (ENS)
Posts: 17
Joined: Mon Jun 02, 2008 1:54 pm

Re: Creating a new user with NUnit

Post by MarkI » Mon Oct 06, 2008 9:40 am

SolunarServices wrote:Does it automate (i.e. simulate) the user input?
NUnit and the concept of unit testing doesn't necessarily cover user input. Unit testing is meant to test an application's methods and class design by verifying that what you wrote does what you intend it to do. Unit testing typically falls under the test driven development methodology whereby the tests are actually written before the code. Once your code passes the unit tests then the idea is you can feel confident that your code not only works, but also does what you want it to.

With regard to user input, unit testing does not do any user simulation. However, you will most certainly create some test data with which to run your unit tests, so that may help you some.

If you google UNnit and tdd (for test driven development) you will find many resources. A quick search turned up this article which does a decent job of explaining the process.

Mark Iverson
Iverson Software

User avatar
Logan Rhodehamel
Developer
Developer
Posts: 4116
Joined: Wed Dec 10, 2003 5:26 pm

Re: Creating a new user with NUnit

Post by Logan Rhodehamel » Thu Oct 09, 2008 3:27 pm

Early AC7 development goal was to make extensive use of NUnit. We couldn't quite make it happen the way I wanted, and then the reasons for the goal changed. In AC5 we had a lot of hand written code that contained simple errors - TDD would have caught those. In AC7, the bulk of our code is generated. The errors we were looking to trap were already elminated.

Another tool that is helpful (if dated) is Microsoft Web Application Stress Tool. I use this to simulate user input somewhat. Scripts can actually be quite complex if you make use of variables.

But in the end, we haven't found a tool that can replicate the efficiency of human testing for the front end scripts.

I am sure additional automated testing (perhaps NUnit or a combination of tools ) will return to the AC7 goal sheet. Some things are awful to test (e.g. discounts) but often have to be retested due to other changes. Since we can determine the expected results, I am looking to automate some of these time consuming tests.
Cheers,
Logan
Image.com

If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.

Post Reply