Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 35cfbcfe9dc17e422fab1bf6b28b374d6df128ed @robdmoore committed Mar 9, 2011
Showing with 44,457 additions and 0 deletions.
  1. +13 −0 .gitignore
  2. +19 −0 LICENSE
  3. +20 −0 QUnitValidation.sln
  4. +136 −0 QUnitValidation/JavaScriptTests.cs
  5. +36 −0 QUnitValidation/Properties/AssemblyInfo.cs
  6. +79 −0 QUnitValidation/QUnitValidation.csproj
  7. +5 −0 QUnitValidation/packages.config
  8. +48 −0 QUnitValidation/test.html
  9. +4 −0 README.md
  10. BIN packages/NUnit.2.5.9.10348/Logo.ico
  11. BIN packages/NUnit.2.5.9.10348/NUnit.2.5.9.10348.nupkg
  12. +277 −0 packages/NUnit.2.5.9.10348/NUnitFitTests.html
  13. +277 −0 packages/NUnit.2.5.9.10348/Tools/NUnitFitTests.html
  14. +85 −0 packages/NUnit.2.5.9.10348/Tools/NUnitTests.config
  15. +14 −0 packages/NUnit.2.5.9.10348/Tools/NUnitTests.nunit
  16. +4 −0 packages/NUnit.2.5.9.10348/Tools/agent.conf
  17. +18 −0 packages/NUnit.2.5.9.10348/Tools/agent.log.conf
  18. +18 −0 packages/NUnit.2.5.9.10348/Tools/launcher.log.conf
  19. BIN packages/NUnit.2.5.9.10348/Tools/lib/Failure.png
  20. BIN packages/NUnit.2.5.9.10348/Tools/lib/Ignored.png
  21. BIN packages/NUnit.2.5.9.10348/Tools/lib/Inconclusive.png
  22. BIN packages/NUnit.2.5.9.10348/Tools/lib/Skipped.png
  23. BIN packages/NUnit.2.5.9.10348/Tools/lib/Success.png
  24. BIN packages/NUnit.2.5.9.10348/Tools/lib/fit.dll
  25. BIN packages/NUnit.2.5.9.10348/Tools/lib/log4net.dll
  26. BIN packages/NUnit.2.5.9.10348/Tools/lib/nunit-console-runner.dll
  27. BIN packages/NUnit.2.5.9.10348/Tools/lib/nunit-gui-runner.dll
  28. BIN packages/NUnit.2.5.9.10348/Tools/lib/nunit.core.dll
  29. BIN packages/NUnit.2.5.9.10348/Tools/lib/nunit.core.interfaces.dll
  30. BIN packages/NUnit.2.5.9.10348/Tools/lib/nunit.fixtures.dll
  31. BIN packages/NUnit.2.5.9.10348/Tools/lib/nunit.uiexception.dll
  32. BIN packages/NUnit.2.5.9.10348/Tools/lib/nunit.uikit.dll
  33. BIN packages/NUnit.2.5.9.10348/Tools/lib/nunit.util.dll
  34. BIN packages/NUnit.2.5.9.10348/Tools/nunit-agent-x86.exe
  35. +69 −0 packages/NUnit.2.5.9.10348/Tools/nunit-agent-x86.exe.config
  36. BIN packages/NUnit.2.5.9.10348/Tools/nunit-agent.exe
  37. +69 −0 packages/NUnit.2.5.9.10348/Tools/nunit-agent.exe.config
  38. BIN packages/NUnit.2.5.9.10348/Tools/nunit-console-x86.exe
  39. +69 −0 packages/NUnit.2.5.9.10348/Tools/nunit-console-x86.exe.config
  40. BIN packages/NUnit.2.5.9.10348/Tools/nunit-console.exe
  41. +69 −0 packages/NUnit.2.5.9.10348/Tools/nunit-console.exe.config
  42. BIN packages/NUnit.2.5.9.10348/Tools/nunit-x86.exe
  43. +83 −0 packages/NUnit.2.5.9.10348/Tools/nunit-x86.exe.config
  44. BIN packages/NUnit.2.5.9.10348/Tools/nunit.exe
  45. +83 −0 packages/NUnit.2.5.9.10348/Tools/nunit.exe.config
  46. BIN packages/NUnit.2.5.9.10348/Tools/nunit.framework.dll
  47. BIN packages/NUnit.2.5.9.10348/Tools/pnunit-agent.exe
  48. +77 −0 packages/NUnit.2.5.9.10348/Tools/pnunit-agent.exe.config
  49. BIN packages/NUnit.2.5.9.10348/Tools/pnunit-launcher.exe
  50. +77 −0 packages/NUnit.2.5.9.10348/Tools/pnunit-launcher.exe.config
  51. BIN packages/NUnit.2.5.9.10348/Tools/pnunit.framework.dll
  52. BIN packages/NUnit.2.5.9.10348/Tools/pnunit.tests.dll
  53. BIN packages/NUnit.2.5.9.10348/Tools/runFile.exe
  54. +43 −0 packages/NUnit.2.5.9.10348/Tools/runFile.exe.config
  55. +2 −0 packages/NUnit.2.5.9.10348/Tools/runpnunit.bat
  56. +24 −0 packages/NUnit.2.5.9.10348/Tools/test.conf
  57. +342 −0 packages/NUnit.2.5.9.10348/fit-license.txt
  58. BIN packages/NUnit.2.5.9.10348/lib/nunit.framework.dll
  59. +10,385 −0 packages/NUnit.2.5.9.10348/lib/nunit.framework.xml
  60. BIN packages/NUnit.2.5.9.10348/lib/nunit.mocks.dll
  61. BIN packages/NUnit.2.5.9.10348/lib/pnunit.framework.dll
  62. +15 −0 packages/NUnit.2.5.9.10348/license.txt
  63. +57 −0 packages/WatiN.2.0.50/License.txt
  64. +43 −0 packages/WatiN.2.0.50/Readme.txt
  65. +495 −0 packages/WatiN.2.0.50/ReleaseHistory.txt
  66. BIN packages/WatiN.2.0.50/WatiN.2.0.50.nupkg
  67. BIN packages/WatiN.2.0.50/WatiN.chm
  68. BIN packages/WatiN.2.0.50/lib/net20/Interop.SHDocVw.dll
  69. BIN packages/WatiN.2.0.50/lib/net20/Microsoft.mshtml.dll
  70. BIN packages/WatiN.2.0.50/lib/net20/WatiN.Core.dll
  71. +10,456 −0 packages/WatiN.2.0.50/lib/net20/WatiN.Core.xml
  72. BIN packages/WatiN.2.0.50/lib/net35/Interop.SHDocVw.dll
  73. BIN packages/WatiN.2.0.50/lib/net35/Microsoft.mshtml.dll
  74. BIN packages/WatiN.2.0.50/lib/net35/WatiN.Core.dll
  75. +10,471 −0 packages/WatiN.2.0.50/lib/net35/WatiN.Core.xml
  76. BIN packages/WatiN.2.0.50/lib/net40/Interop.SHDocVw.dll
  77. +10,471 −0 packages/WatiN.2.0.50/lib/net40/WatiN.Core.XML
  78. BIN packages/WatiN.2.0.50/lib/net40/WatiN.Core.dll
  79. BIN packages/WatiN.2.0.50/mozilla/jssh-3.6-WINNT.xpi
  80. BIN packages/WatiN.2.0.50/mozilla/jssh-WINNT-2.x.xpi
  81. BIN packages/WatiN.2.0.50/mozilla/jssh-WINNT-3.5.xpi
  82. BIN packages/WatiN.2.0.50/mozilla/jssh-WINNT-3.x.xpi
  83. +4 −0 packages/repositories.config
@@ -0,0 +1,13 @@
+**/obj
+**/bin
+**/deploy
+**/deploy/*
+_ReSharper.*
+**/*.csproj.user
+*.ReSharper.user
+*.ReSharper
+*.suo
+**/*.cache
+~$*
+*~
+*.log
19 LICENSE
@@ -0,0 +1,19 @@
+Copyright (C) 2011 by Miguel Madero and Robert Moore
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QUnitValidation", "QUnitValidation\QUnitValidation.csproj", "{3E79FCC9-E410-49FF-875D-4763F18CD9BB}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {3E79FCC9-E410-49FF-875D-4763F18CD9BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3E79FCC9-E410-49FF-875D-4763F18CD9BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3E79FCC9-E410-49FF-875D-4763F18CD9BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3E79FCC9-E410-49FF-875D-4763F18CD9BB}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
@@ -0,0 +1,136 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Xml.Linq;
+using NUnit.Framework;
+using WatiN.Core;
+
+[assembly: RequiresSTA]
+
+namespace QUnitValidation
+{
+ [TestFixture]
+ public class JavaScriptTests
+ {
+ private IE _ie;
+
+ [TestFixtureSetUp]
+ public void TestFixtureSetup()
+ {
+ _ie = new IE();
+ }
+
+ [Test]
+ public void QUnit()
+ {
+ //test.ShouldPass();
+ var x = RunQUnitTests();
+ }
+
+ [TestFixtureTearDown]
+ public void TestFixtureTearDown()
+ {
+ _ie.Close();
+ }
+
+ public IEnumerable<TestCaseData> RunQUnitTests()
+ {
+ var x = GetQUnitTestResults("test.html").Select(t => new TestCaseData(t));
+ return x;
+ }
+
+
+ public IEnumerable<QUnitTest> GetQUnitTestResults(string testPage)
+ {
+ //var directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
+ var directory = @"C:\Users\Rob\Documents\Visual Studio 2010\Projects\QUnitValidation\QUnitValidation\bin\Debug";
+ var fileName = string.IsNullOrEmpty(directory) ? testPage : Path.Combine(directory, testPage);
+ _ie.GoTo(fileName);
+ _ie.WaitForComplete(5);
+
+ return GrabTestResultsFromWebPage(testPage);
+ }
+
+ public IEnumerable<QUnitTest> GrabTestResultsFromWebPage(string testPage)
+ {
+ // BEWARE: This logic is tightly coupled to the structure of the HTML generated by the QUnit test runner
+ // Also, this could probably be greatly simplified with a couple well-crafted XPath expressions
+ var testOl = _ie.Elements.Filter(Find.ById("tests"))[0];
+ if (testOl == null) yield break;
+ var documentRoot = XDocument.Load(new StringReader(MakeXHtml(testOl.OuterHtml))).Root;
+ if (documentRoot == null) yield break;
+
+ foreach (var listItem in documentRoot.Elements())
+ {
+ var testName = listItem.Elements().First( x => x.Name.Is("strong")).Value;
+ var resultClass = listItem.Attributes().First(x => x.Name.Is("class")).Value;
+ var failedAssert = String.Empty;
+ if (resultClass == "fail")
+ {
+ var specificAssertFailureListItem = listItem.Elements()
+ .First(x => x.Name.Is("ol")).Elements()
+ .First(x => x.Name.Is("li") && x.Attributes().First(a=> a.Name.Is("class")).Value == "fail");
+ if (specificAssertFailureListItem != null)
+ {
+ failedAssert = specificAssertFailureListItem.Value;
+ }
+ }
+
+ yield return new QUnitTest
+ {
+ FileName = testPage,
+ TestName = RemoveAssertCounts(testName),
+ Result = resultClass, Message = failedAssert
+ };
+ }
+
+ }
+
+ private static string MakeXHtml(string html)
+ {
+ return html.Replace("class=pass", "class=\"pass\"")
+ .Replace("class=fail", "class=\"fail\"")
+ .Replace("id=tests", "id=\"tests\"");
+ }
+
+
+ private static string RemoveAssertCounts(string fullTagText)
+ {
+ if (fullTagText == null) return String.Empty;
+ int parenPosition = fullTagText.IndexOf('(');
+ if (parenPosition > 0)
+ {
+ return fullTagText.Substring(0, parenPosition - 1);
+ }
+ return fullTagText;
+ }
+ }
+
+ public class QUnitTest
+ {
+ public string FileName { get; set; }
+ public string TestName { get; set; }
+ public string Result { get; set; }
+ public string Message { get; set; }
+
+ public override string ToString()
+ {
+ return string.Format("[{0}] {1}", FileName, TestName);
+ }
+ }
+
+ public static class QUnitTestHelpers
+ {
+ public static void ShouldPass(this QUnitTest theTest)
+ {
+ Assert.That(theTest.Result.Split(' '), Has.Member("pass"), theTest.Message);
+ }
+
+ public static bool Is(this XName xname, string name)
+ {
+ return xname.ToString().Equals(name, StringComparison.OrdinalIgnoreCase);
+ }
+ }
+}
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("QUnitValidation")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("QUnitValidation")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("94e21876-21c9-49f0-8d87-43b7b708a4da")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{3E79FCC9-E410-49FF-875D-4763F18CD9BB}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>QUnitValidation</RootNamespace>
+ <AssemblyName>QUnitValidation</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Interop.SHDocVw">
+ <HintPath>..\packages\WatiN.2.0.50\lib\net40\Interop.SHDocVw.dll</HintPath>
+ <EmbedInteropTypes>False</EmbedInteropTypes>
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="nunit.framework">
+ <HintPath>..\packages\NUnit.2.5.9.10348\lib\nunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="nunit.mocks">
+ <HintPath>..\packages\NUnit.2.5.9.10348\lib\nunit.mocks.dll</HintPath>
+ </Reference>
+ <Reference Include="pnunit.framework">
+ <HintPath>..\packages\NUnit.2.5.9.10348\lib\pnunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ <Reference Include="WatiN.Core">
+ <HintPath>..\packages\WatiN.2.0.50\lib\net40\WatiN.Core.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="JavaScriptTests.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="test.html">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="NUnit" version="2.5.9.10348" />
+ <package id="WatiN" version="2.0.50" />
+</packages>
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <!--<script src="http://code.jquery.com/jquery-latest.js"></script>
+ <link rel="stylesheet" href="http://code.jquery.com/qunit/git/qunit.css" type="text/css" media="screen" />
+<script type="text/javascript" src="http://code.jquery.com/qunit/git/qunit.js"></script>
+
+ <script>
+ $(document).ready(function () {
+
+ test("a basic test example", function () {
+ ok(true, "this test is fine");
+ var value = "hello";
+ equals("hello", value, "We expect value to be hello");
+ });
+
+ module("Module A");
+
+ test("first test within module", function () {
+ ok(true, "all pass");
+ });
+
+ test("second test within module", function () {
+ ok(true, "all pass");
+ });
+
+ module("Module B");
+
+ test("some other test", function () {
+ expect(2);
+ equals(true, false, "failing test");
+ equals(true, true, "passing test");
+ });
+
+ });
+ </script>-->
+
+</head>
+<body>
+ <h1 id="qunit-header">QUnit example</h1>
+ <h2 id="qunit-banner"></h2>
+ <div id="qunit-testrunner-toolbar"></div>
+ <h2 id="qunit-userAgent"></h2>
+ <ol id="qunit-tests"></ol>
+ <div id="qunit-fixture">test markup, will be hidden</div>
+</body>
+</html>
@@ -0,0 +1,4 @@
+jQuery QUnit in NUnit
+=====================
+
+Runs QUnit tests inside NUnit by using WatiN. Based on http://www.lostechies.com/blogs/joshuaflanagan/archive/2008/09/18/running-jquery-qunit-tests-under-continuous-integration.aspx, but updated to work with NUnit 2.5.9 and WatiN 2.0.5.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.

0 comments on commit 35cfbcf

Please sign in to comment.