nspec / NSpec

A battle hardened testing framework for C# that's heavily inspired by Mocha and RSpec.
http://nspec.org/
MIT License
260 stars 57 forks source link

NSpecRunner not pulling right class name #6

Closed thumper631 closed 13 years ago

thumper631 commented 13 years ago

Morning,

When I run dotnet.watchr.rb in the background and save the file, the running spec seems to be grabbing "describe_My_Class" instead of "My_Class". If I rename the class to "describe_My_Class", the application trys to find "describe_describe_My_Class" My project is called "ABC.Test". Any idea on how I might be able to correct this?

Thanks for a great test framework....

James

mattflo commented 13 years ago

Hi James!

I'm sorry you are having difficulties. I'm glad to hear you like the framework!

Be sure you are on the latest version of Specwatchr - 1.4.3 http://nuget.org/List/Packages/specwatchr

It will also help if you paste the output from starting specwatchr and then saving the file.

-Matt

amirrajan commented 13 years ago

Hey James,

I've seen this happen sometimes when the ruby gem (watchr) doesn't pick up the changes to the file correctly. Try this and let me know if you still have the problem: stop watchr (ctrl+c in the command window), in visual studio, make sure all files have been saved (ctrl+shift+s), restart specwatchr and see if the problem is resolved. I did try to recreate and I wasn't able to. Let me know and thanks for the kind words!

-Amir

thumper631 commented 13 years ago

Afternoon,

thanks for the quick response. No joy. I have specwatchr 1.4.3 and NSpec 0.9.40 install. Here is the output from specwatchr

====================== changed: UMS_Processor_Requirement_qq1.cs ===============

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" "./UMM.Test.sln" /verbosity:quiet /nologo

=========== running spec: describe_UMS_Processor_Requirement_qq1 ===== "./packages/nspec.0.9.40/tools/NSpecRunner.exe" "bin/Debug/NSpec.dll" "describe_UMS_Processor_Requirement_qq1"

0 Examples, 0 Failed, 0 Pending

===================== done consider ========================

Specification C# File

using System; using NSpec;

namespace UMM.Test { public class UMS_Processor_Requirement_qq1 : nspec { void UMS_Processor_Requirement() { // REQUIREMNT 1 context["Extract ABC truck Files from Data Transfer File"] = () => { context["REQ-1.1: The system shall utilize the extraction dll [Ref XXXX provide by XXXX] to extract filght files from the RTRE file."] = () => { describe["when processing a RTRE file"] = () => { it["a vertical file is created "] = todo; it["a horizal file is created"] = todo; it["a z-base file is created"] = () => "1".should_be("11"); it["a garbage should be empty "] = () => "1".should_be("1"); }; };

            context["REQ-1.2: The system shall open a Tree Log UI."] = () =>               
            {
                describe["after processing a RTRE file"] = () =>
                 {
                     it["the system will show the user a Tree log report"] = todo;
                 };
            };

            context["REQ-1.3: The system shall create records for each truck event in the TRETR event table."] = () =>
                {
                    describe["when processing a RTRE file"] = () =>
                     {
                         it["the system will create one record per truck found in the RTRE file."] = todo;
                     };
                };

            context["REQ-1.4: The system shall calculate and write header details."] = () =>
                {
                    describe["when processing a RTRE file"] = () =>
                     {
                         it["the system will create calculate header details"] = todo;
                         it["store the data"] = todo;
                     };
                };

            context["REQ-1.5: The system shall calculate and write trucks details."] = () =>
                {
                    describe["when processing a RTRE file"] = () =>
                     {
                         it["the system will create calculate header details"] = todo;
                         it["store the data"] = todo;
                     };
                };
        };

        // REQUIREMNT 2
        context["Process truck FIle (Calculate Header and Truck details)"] = () =>
        {
            context["REQ-2.1: The system shall write the following data to the TRETR truck Event Table"] = () =>
               {
                   context["when given truck data, the system will write the following data to the truck Event Table"] = () =>
                    {
                        it["Table Number"] = todo;
                        it["File date and time"] = todo;
                        it["MWA Data"] = todo;
                        context["Header status (e.g. Complete, Partial and Not Complete)"] = () =>
                            {
                                it["Complete"] = todo;
                                it["Partial"] = todo;
                                it["Not Complete"] = todo;  
                            };
                        it["System information (Memos)"] = todo;
                        it["TRETR & EEW software versions"] = todo;
                        it["System failures (Ref. FTHeader.Healthfailure"] = todo;
                    };
               };
            context["REQ-2.2: The systen shall convert (as Necessary) and store raw channel data against the truck Event"] = () =>
                {
                    describe["when given raw channel data for truck events"] = () =>
                        {
                            it["convert data as needed"] = todo;
                            it["store the data"] = todo;
                        };
                };
        };
    }
}

}

Directory Structure

Volume in drive D is Hard Disk D Volume Serial Number is C4FE-2FE5

Directory of D:\Prj\UMM.Test

05/22/2011 05:24 PM

. 05/22/2011 05:24 PM .. 05/21/2011 04:13 PM bin 05/22/2011 05:24 PM 0 dir.txt 05/21/2011 07:37 PM 3,454 dotnet.watchr.rb 05/21/2011 04:10 PM 22,552 green.png 05/21/2011 04:09 PM obj 05/21/2011 04:10 PM packages 05/21/2011 04:10 PM 109 packages.config 05/21/2011 04:09 PM Properties 05/21/2011 04:10 PM 22,049 red.png 05/21/2011 04:10 PM 801 specwatchr-usage.txt 05/21/2011 07:56 PM 2,648 UMM.Test.csproj 05/21/2011 07:37 PM 2,569 UMM.Test.sln 05/22/2011 05:22 PM 4,365 UMS_Processor_Requirement_qq1.cs 05/21/2011 04:10 PM 22,036 watcher_dot_net.rb 10 File(s) 80,583 bytes

Directory of D:\Prj\UMM.Test\bin

05/21/2011 04:13 PM

. 05/21/2011 04:13 PM .. 05/22/2011 03:32 PM Debug 05/21/2011 04:13 PM Release 0 File(s) 0 bytes

Directory of D:\Prj\UMM.Test\bin\Debug

05/22/2011 03:32 PM

. 05/22/2011 03:32 PM .. 05/21/2011 04:10 PM 34,304 NSpec.dll 05/21/2011 04:10 PM 135,168 nunit.framework.dll 05/22/2011 05:22 PM 9,728 UMM.Test.dll 05/22/2011 05:22 PM 17,920 UMM.Test.pdb 4 File(s) 197,120 bytes

Directory of D:\Prj\UMM.Test\bin\Release

05/21/2011 04:13 PM

. 05/21/2011 04:13 PM .. 0 File(s) 0 bytes

Directory of D:\Prj\UMM.Test\obj

05/21/2011 04:09 PM

. 05/21/2011 04:09 PM .. 05/22/2011 05:22 PM Debug 0 File(s) 0 bytes

Directory of D:\Prj\UMM.Test\obj\Debug

05/22/2011 05:22 PM

. 05/22/2011 05:22 PM .. 05/22/2011 05:13 PM 5,784 DesignTimeResolveAssemblyReferencesInput.cache 05/22/2011 11:31 AM 7,054 ResolveAssemblyReference.cache 05/21/2011 04:09 PM TempPE 05/22/2011 04:56 PM 302 UMM.Test.csproj.FileListAbsolute.txt 05/22/2011 05:22 PM 9,728 UMM.Test.dll 05/22/2011 05:22 PM 17,920 UMM.Test.pdb 5 File(s) 40,788 bytes

Directory of D:\Prj\UMM.Test\obj\Debug\TempPE

05/21/2011 04:09 PM

. 05/21/2011 04:09 PM .. 0 File(s) 0 bytes

Directory of D:\Prj\UMM.Test\packages

05/21/2011 04:10 PM

. 05/21/2011 04:10 PM .. 05/21/2011 04:10 PM nspec.0.9.40 05/22/2011 05:22 PM 183 repositories.config 05/21/2011 04:10 PM specwatchr.1.4.3 1 File(s) 183 bytes

Directory of D:\Prj\UMM.Test\packages\nspec.0.9.40

05/21/2011 04:10 PM

. 05/21/2011 04:10 PM .. 05/21/2011 04:10 PM lib 05/21/2011 04:10 PM 212,277 nspec.0.9.40.nupkg 05/21/2011 04:10 PM tools 1 File(s) 212,277 bytes

Directory of D:\Prj\UMM.Test\packages\nspec.0.9.40\lib

05/21/2011 04:10 PM

. 05/21/2011 04:10 PM .. 05/21/2011 04:10 PM 34,304 NSpec.dll 05/21/2011 04:10 PM 135,168 nunit.framework.dll 2 File(s) 169,472 bytes

Directory of D:\Prj\UMM.Test\packages\nspec.0.9.40\tools

05/21/2011 04:10 PM

. 05/21/2011 04:10 PM .. 05/21/2011 04:10 PM 34,304 NSpec.dll 05/21/2011 04:10 PM 155,136 NSpec.pdb 05/21/2011 04:10 PM 6,144 NSpecRunner.exe 05/21/2011 04:10 PM 15,872 NSpecRunner.pdb 05/21/2011 04:10 PM 11,600 NSpecRunner.vshost.exe 05/21/2011 04:10 PM 490 NSpecRunner.vshost.exe.manifest 05/21/2011 04:10 PM 135,168 nunit.framework.dll 7 File(s) 358,714 bytes

Directory of D:\Prj\UMM.Test\packages\specwatchr.1.4.3

05/21/2011 04:10 PM

. 05/21/2011 04:10 PM .. 05/21/2011 04:10 PM 56,639 specwatchr.1.4.3.nupkg 05/21/2011 04:10 PM tools 1 File(s) 56,639 bytes

Directory of D:\Prj\UMM.Test\packages\specwatchr.1.4.3\tools

05/21/2011 04:10 PM

. 05/21/2011 04:10 PM .. 05/21/2011 04:10 PM 3,454 dotnet.watchr.rb 05/21/2011 04:10 PM 22,552 green.png 05/21/2011 04:10 PM 715 init.ps1 05/21/2011 04:10 PM 22,049 red.png 05/21/2011 04:10 PM 801 specwatchr-usage.txt 05/21/2011 04:10 PM 22,036 watcher_dot_net.rb 6 File(s) 71,607 bytes

Directory of D:\Prj\UMM.Test\Properties

05/21/2011 04:09 PM

. 05/21/2011 04:09 PM .. 05/21/2011 04:09 PM 1,446 AssemblyInfo.cs 1 File(s) 1,446 bytes

 Total Files Listed:
          38 File(s)      1,188,829 bytes
          41 Dir(s)  180,138,180,608 bytes free

Hope this is enough information for you to solve the issues.

James

amirrajan commented 13 years ago

Thanks for the output, I am going to see if I can recreate it.

As a temporary fix, you can explicitly specify your test dll in dotnet.watchr.rb by using the following lines (it's line 40 in dotnet.watchr.rb): @dw.test_runner.test_dlls = ['D:\Prj\UMM.Test\bin\Debug\UMM.Test.dll']

The issue is that specwatchr is attempting to run specifications against the NSpec.dll as opposed to your's:

=========== running spec: describe_UMS_Processor_Requirement_qq1 ===== "./packages/nspec.0.9.40/tools/NSpecRunner.exe" "bin/Debug/NSpec.dll" "describe_UMS_Processor_Requirement_qq1"

I'll set up a similar project structure and try to recreate it, for now see if the temporary fix works.

Thank you for the detailed output, It's really appreciated!

thumper631 commented 13 years ago

Amir, Thanks once more for the quick response. I made the changes like you suggest and "Watchr" is firing off as expected (this was happening before). I am still seeing that it is trying to get describe_...

====================== changed: UMS_Processor_Requirement_qq1.cs ===============

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" "./UMM.Test.sln" /ve rbosity:quiet /nologo

=========== running spec: describe_UMS_Processor_Requirement_qq1 ===== "./packages/nspec.0.9.40/tools/NSpecRunner.exe" "D:\Dropbox\Projects\UMM.Test\bin\Debug\UMM.Test.dll" "describe_UMS_Processor_Requirement_qq1"

0 Examples, 0 Failed, 0 Pending

===================== done consider ========================

Thanks again for your help

James

p.s.

On a side note, I spend part of the weekend writing a parser for the output. My idea is to add it into the build progess and have it save a HTML file on the server were both my manager and the BA could review it to see where we are at. Now I am not a web design or graphic artist but for a first pass at it, I think that it will allow for everyone to be on the same page. I will forward a copy of the output to your email.

amirrajan commented 13 years ago

I see another problem that may be the cause, your nspec test class must match the following convention:

I'd be more than happy to walk you through the changes you'd need to make, so don't hesitate to ask!

thumper631 commented 13 years ago

Sorry did not mean to close it

Amri,

Thanks for the update. I rename the file as you ask and now I am getting the following :)

USAGE INSTRUCTIONS FOR NSpecRunner Discovered and using:

====================== changed: describe_UMS_Processor_Requirement_qq1.cs ======

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" "./UMM.Test.sln" /verbosity:quiet /nologo

=========== running spec: describe_describe_UMS_Processor_Requirement_qq1 ===== "./packages/nspec.0.9.40/tools/NSpecRunner.exe" "D:\Dropbox\Projects\UMM.Test\bin\Debug\UMM.Test.dll" "describe_describe_UMS_Processor_Requirement_qq1"

0 Examples, 0 Failed, 0 Pending

===================== done consider ========================

Any other ideas? Header now looks like the following:

using System; using NSpec;

namespace UMM.Test { public class describe_UMS_Processor_Requirement_qq1 : nspec { void UMS_Processor_Requirement() { // REQUIREMNT 1 ...

and the file is "describe_UMS_Processor_Requirement_qq1.cs"

Thanks again,

James

amirrajan commented 13 years ago

We're getting closer it seems. This definitely looks like a bug in specwatchr. I'll keep you updated, thanks again for helping me narrow this down.

thumper631 commented 13 years ago

Amir,

Anytime and thank you for your help in trying to solve this issue. I am looking forward to "show & tell" this week at the office to show the potential benefits of using this framework.

James

amirrajan commented 13 years ago

Hey James,

Would mind trying the following? It's a stab in the dark that may confirm the bug.

Try changing line 40 in dotnet.watchr.rb to use a relative path as opposed to an explicit path: @dw.test_runner.test_dlls = ['./UMM.Test/bin/Debug/UMM.Test.dll']

The relative path should start from the path where specwatchr lives. Usually .csproj files live in folders adjacent to the .sln file. The challenge here is that describe_UMS_Processor_Requirement_qq1.cs also lives adjacent to the .sln file.

I'm pretty sure that specwatchr will work if you have the following folder structure:

Link to image: http://imgur.com/HgENt

mattflo commented 13 years ago

I've replicated both issues:

a) not finding correct spec DLL b) incorrectly prepending describe_

I can confirm both are a result of the flat directory structure. If you use the structure Amir outlined above everything works correctly.

Do you commonly use this non-standard directory layout? If so, why? Do you believe this is a common scenario specwatchr should be made to work with?

Thanks for all the help in diagnosing this problem. Let me know if you have any more questions.

thumper631 commented 13 years ago

Matt/Amir

Good question on structure. I was not aware of any reason to follow the structure that Amir had liad out. I refactor my directories to follow the structure that Amir laid out and everything is working great now. Thank you for taking the time in helping me on this.

James

p.s.

Quick question? SInce my "Ruby Kung-Fu" is not so great, I'm wondering if you tell me where about and maybe what sort of ruby code I would need to run my SpectToHTMLparser? What I am hoping for is that after the test runs, I could get it to make a parser call. ie: after

=========== running spec: describe_UMS_Processor ===== "./packages/nspec.0.9.41/tools/NSpecRunner.exe" "Umm.Test/bin/Debug/Umm.Test.dll" "describe_UMS_Processor"

it would run something like

NSpecRunner.exe "Umm.Test/bin/Debug/Umm.Test.dll" "describe_UMS_Processor" >> UMS_Processor.txt SpectToHTMLparser.exe UMS_Processor.txt UMS_Processor.HTML (my parser takes a text file and outputs to an HTML)

Thanks once again

mattflo commented 13 years ago

I didn't realize you are parsing the output after the fact into html. I think implementing a new HTMLFormatter in the c# codebase might be a better approach. It would be an alternative formatter to the default ConsoleFormatter. Eventually command line switches would let you swap formatters. If you are up for it, feel free to fork and give it a shot. Jason is interested in the same feature. I don't think he's started working on it. Here's his github https://github.com/jgill13

I'm happy to help get you involved so don't hesitate to ask if you have more questions.

mattflo commented 13 years ago

James,

Just an update on this issue. We've seen other people with this problem and now understand why it happens somewhat regularly. I've opened an issue on the specwatchr project.

https://github.com/amirrajan/SpecWatchr/issues/1