dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/csunit Makefile.am,1.5,1.6 NUnitEmul


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/csunit Makefile.am,1.5,1.6 NUnitEmulation.cs,NONE,1.1 Test.cs,1.2,1.3 TestArray.cs,1.2,1.3 TestAssertFailed.cs,1.2,1.3 TestCase.cs,1.3,1.4 TestException.cs,1.2,1.3 TestFailure.cs,1.2,1.3 TestMain.cs,1.6,1.7 TestResult.cs,1.2,1.3 TestStop.cs,1.2,1.3 TestSuite.cs,1.4,1.5 TestVersion.cs.in,1.2,1.3 TestWriterResult.cs,1.2,1.3 csunit-run.sh,NONE,1.1 csunit.build,NONE,1.1 README,1.2,1.3
Date: Sat, 07 Dec 2002 21:12:10 -0500

Update of /cvsroot/dotgnu-pnet/pnetlib/csunit
In directory subversions:/tmp/cvs-serv23306/csunit

Modified Files:
        README 
Added Files:
        Makefile.am NUnitEmulation.cs Test.cs TestArray.cs 
        TestAssertFailed.cs TestCase.cs TestException.cs 
        TestFailure.cs TestMain.cs TestResult.cs TestStop.cs 
        TestSuite.cs TestVersion.cs.in TestWriterResult.cs 
        csunit-run.sh csunit.build 
Log Message:


Copy "csunit" back into pnetlib so that we can eventually remove
all C# code from "pnet".



--- NEW FILE ---
/*
 * NUnitEmulation.cs - Emulate enough of the NUnit test interface to
 *                     be able to run tests from the Mono class library.
 *
 * Copyright (C) 2002  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace NUnit.Framework
{

using System;

public class TestResult : CSUnit.TestResult
{
        // Constructors.
        public TestResult() : base() {}

}; // class TestResult

public interface ITest : CSUnit.Test
{
}; // interface ITest

public abstract class TestCase : CSUnit.TestCase, ITest
{

        // Constructors.
        public TestCase() : this(String.Empty) {}
        public TestCase(String name) : base(name) {}

        // Create an NUnit-style result object.
        public override CSUnit.TestResult CreateResult()
                        {
                                return new TestResult();
                        }

        // Set up for the test.
        protected virtual void SetUp() {}
        protected override void Setup()
                        {
                                SetUp();
                        }

        // Tear down after the test.
        protected virtual void TearDown() {}
        protected override void Cleanup()
                        {
                                TearDown();
                        }

        // Convert this object into a string.
        public override String ToString()
                        {
                                return Name;
                        }

}; // class TestCase

public class TestSuite : CSUnit.TestSuite
{
        // Constructors.
        public TestSuite() : base(String.Empty) {}
        public TestSuite(String name) : base(name) {}
        public TestSuite(Type type, bool suppressWarnings)
                        : base(type.Name, type) {}
        public TestSuite(Type type) : base(type.Name, type) {}

        // Add a test to this suite.
        public void AddTest(ITest test)
                        {
                                base.AddTest(test);
                        }

        // Add another test suite to this one.
        public void AddTestSuite(Type type)
                        {
                                AddTest(new TestSuite(type));
                        }

}; // class TestSuite

}; // namespace NUnit.Framework













--- NEW FILE ---
#!/usr/bin/env clrwrap
csunit.exe

--- NEW FILE ---
<?xml version="1.0"?>
<project name="csunit" default="all">
        <target name="all">

                <!-- Build the cstest.dll library -->
                <compile output="cstest.dll"
                                 target="library"
                                 unsafe="true"
                                 nostdlib="true"
                                 optimize="true"
                                 debug="true">

                        <sources>
                                <includes name="**/*.cs"/>
                                <excludes name="TestMain.cs"/>
                        </sources>

                        <references>
                                <file name="../runtime/mscorlib.dll"/>
                        </references>

                        <arg compiler="cscc" value="-Wno-empty-input"/>
                        <arg compiler="csc" value="/nowarn:626"/>
                        <arg compiler="csc" value="/nowarn:649"/>
                        <arg compiler="csc" value="/nowarn:168"/>
                        <arg compiler="csc" value="/nowarn:67"/>
                        <arg compiler="csc" value="/nowarn:169"/>
                </compile>

                <!-- Build the csunit.exe program -->
                <compile output="csunit.exe"
                                 target="exe"
                                 unsafe="true"
                                 nostdlib="true"
                                 optimize="true"
                                 debug="true">

                        <sources>
                                <file name="TestMain.cs"/>
                        </sources>

                        <references>
                                <file name="cstest.dll"/>
                                <file name="../runtime/mscorlib.dll"/>
                        </references>

                        <arg compiler="cscc" value="-Wno-empty-input"/>
                        <arg compiler="csc" value="/nowarn:626"/>
                        <arg compiler="csc" value="/nowarn:649"/>
                        <arg compiler="csc" value="/nowarn:168"/>
                        <arg compiler="csc" value="/nowarn:67"/>
                        <arg compiler="csc" value="/nowarn:169"/>
                </compile>

        </target>
</project>

Index: README
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/csunit/README,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** README      17 Sep 2002 22:43:29 -0000      1.2
--- README      8 Dec 2002 02:12:07 -0000       1.3
***************
*** 1 ****
! The csunit code has been moved into the pnet distribution.
--- 1,138 ----
! What is CSUnit?
! --------------
! 
! CSUnit is a stripped-down unit testing framework, based loosely on
! JUnit and NUnit.  It doesn't have a fancy UI, as it is designed for
! batch testing within an automake framework.
! 
! CSUnit also is very conservative as to the features it uses from the
! C# system library.  It tries not to rely upon the library for critical
! data structures, because the library data structures may not work yet!
! This makes CSUnit more suitable for self-testing the C# library than
! the more general-purpose frameworks.
! 
! The last reason why we use CSUnit instead of NUnit is licensing.
! The Portable.NET package is part of the DotGNU project, and as such we
! must use GPL-compatible software at all times.  NUnit's license doesn't
! appear to be compatible with the GPL.
! 
! Writing test cases
! ------------------
! 
! To create a test class, inherit from the "TestCase" class and override
! the "Setup" and "Cleanup" methods.  Then add methods that start with
! the name "Test" to define each of the tests for this test case.
! 
!     using System;
!     using CSUnit;
! 
!     public class TestFoo : TestCase
!     {
!         public TestFoo(String name) : base(name) {}
! 
!         protected override void Setup()
!             {
!                 // Perform setup tasks for the tests in this class.
!                 ...
!             }
! 
!         protected override void Cleanup()
!             {
!                 // Perform cleanup tasks for the tests in this class.
!                 ...
!             }
! 
!         public void TestFooA()
!             {
!                 // First test for "Foo".
!                 ...
!             }
! 
!         public void TestFooB()
!             {
!                 // Second test for "Foo".
!                 ...
!             }
! 
!         ...
!     }
! 
! A test succeds when it returns successfully from the method.  A test
! fails when it throws an exception.  The easiest way to cause a test
! failure is to call the "Fail()" method, or to call "Assert()" on a
! condition that is false.  The "TestCase" base class contains a number
! of useful methods for failing on various conditions.
! 
! Creating a test suite
! ---------------------
! 
! Once you have built your test cases, you need to wrap them up in
! a test suite so that CSUnit can find them at run time.  The easiest
! way to do this is to create a class with the same name as the
! assembly.  e.g. if your test assembly is called "TestBar.dll", then
! your should create a "TestBar" class as follows:
! 
!     using System;
!     using CSUnit;
! 
!     public class TestBar
!     {
!         public static TestSuite Suite()
!             {
!                 // Create the primary test suite.
!                 TestSuite suite = new TestSuite("Foo Tests");
! 
!                 // Add all of the tests in the "TestFoo" and
!                 // "TestBaz" types to the suite.
!                 suite.AddTests(typeof(TestFoo));
!                 suite.AddTests(typeof(TestBaz));
! 
!                 // Return the suite to the CSUnit test engine.
!                 return suite;
!             }
!     }
! 
! If you have multiple test suites in the same assembly, then you should
! create a "super-suite" and chain them together.
! 
!     using System;
!     using CSUnit;
! 
!     public class TestBar
!     {
!         public static TestSuite Suite()
!             {
!                 TestSuite suite = new TestSuite("Foo Tests");
!                 suite.AddTest(TestFoo1.Suite());
!                 suite.AddTest(TestFoo2.Suite());
!                 return suite;
!             }
!     }
! 
!     public class TestFoo1
!     {
!         public static TestSuite Suite()
!             {
!                 TestSuite suite = new TestSuite("Foo1 Tests");
!                 suite.AddTests(typeof(TestFoo1a));
!                 suite.AddTests(typeof(TestFoo1b));
!                 suite.AddTests(typeof(TestFoo1c));
!                 return suite;
!             }
!     }
! 
!     public class TestFoo2
!     {
!         public static TestSuite Suite()
!             {
!                 TestSuite suite = new TestSuite("Foo2 Tests");
!                 suite.AddTests(typeof(TestFoo2a));
!                 suite.AddTests(typeof(TestFoo2b));
!                 suite.AddTests(typeof(TestFoo2c));
!                 suite.AddTests(typeof(TestFoo2d));
!                 return suite;
!             }
!     }
! 
! The test assembly must be compiled and linked against "cstest.dll" to
! obtain the necessary CSUnit definitions.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]