JScript を使う >> UnitTest Framework >> Script Unit

Script Unit


Script Unit は COM を使ったユニットテスト フレームワークです。ウインドウズ環境下において WSH をサポートする ActiveScript から使用します。 LGPL ライセンスで配布されています。

配布元および使用したバージョンは次の通りです。
Script Unit
http://www.xt1.org/scriptunit/
- ScriptUnit-0.8.zip

インストール


ScriptUnit.exe を使うには COM サーバを登録するか manifest ファイルを作成します。 Windows XP であれば、セキュリティの面から manifest ファイルの使用をお勧めします。

COM サーバに登録する


コマンドプロンプトかファイル名を指定して実行ダイアログから ScriptUnit.exe に /regserver を渡して登録します。未確認。
ScriptUnit.exe /regserver

登録を削除する。


コマンドプロンプトかファイル名を指定して実行ダイアログから ScriptUnit.exe に /unregserver を渡して登録を削除します。未確認。
ScriptUnit.exe /unregserver

manifest ファイルを使う。


下記 XML を ScriptUnit.exe.manifest のファイル名で ScriptUnit.exe と同じディレクトリに保存します。このファイルは ScriptUnit 作者に献呈します。
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
    version="0.8.0.10"
    processorArchitecture="x86"
    name="Christian Mogensen.ScriptUnit"
    type="win32"
/>
<description>Unit testing of COM components using ActiveX Scripting</description>
<file name="ScriptUnit.exe">
    <comClass
        description="ScriptUnit Assert Class"
        clsid="{2D2F9461-3E23-11D8-AC46-0050044DE41E}"
        progid="ScriptUnit.Assert.1"
        tlbid="{A5187C62-3BBE-11d8-AC47-0050044DE41E}">
        <progid>ScriptUnit.Assert</progid>
    </comClass>
    <comClass
        description="WinCommander Class"
        clsid="{B9ADB7F6-FDF6-4BF1-90AA-A4F6325A585B}"
        progid="ScriptUnit.WinCommander.1"
        tlbid="{A5187C62-3BBE-11d8-AC47-0050044DE41E}">
        <progid>ScriptUnit.WinCommander</progid>
    </comClass>
    <comClass
        description="Engine Class"
        clsid="{C038263B-2951-4FF5-B241-919E4F967524}"
        progid="ScriptUnit.Engine.1"
        tlbid="{A5187C62-3BBE-11d8-AC47-0050044DE41E}">
        <progid>ScriptUnit.Engine</progid>
    </comClass>
    <typelib
        tlbid="{A5187C62-3BBE-11d8-AC47-0050044DE41E}"
        version="1.0"
        helpdir=""
        flags=""
    />
</file>
<file name="TestObject.dll">
    <comClass
        description="Good Class"
        clsid="{3899ACC0-1985-4F52-AD74-4651232849A6}"
        progid="TestObject.Good.1"
        threadingModel="Apartment"
        tlbid="{DBC72810-DF3D-4C29-B7CA-798C8CE094E0}">
        <progid>TestObject.Good</progid>
    </comClass>
    <comClass
        description="Bad Class"
        clsid="{21FB74E8-4484-4F4B-BD5A-9BBA0F5273AE}"
        progid="TestObject.Bad.1"
        threadingModel="Apartment"
        tlbid="{DBC72810-DF3D-4C29-B7CA-798C8CE094E0}">
        <progid>TestObject.Bad</progid>
    </comClass>
    <typelib
        tlbid="{DBC72810-DF3D-4C29-B7CA-798C8CE094E0}"
        version="1.0"
        helpdir=""
        flags=""
    />
</file>
</assembly>
<!--
references:

Side-by-Side Manifest Contents - Complete Example
http://www.mazecomputer.com/sxs/help/inside2.htm
 -->

Assert

メソッド一覧

Assert.IsTrue( expr, [msg] )Log if expr is false.
Assert.IsFalse( expr, [msg] )Log if expr is true.
Assert.Equal( a, b, [msg] )
Assert.Equals( a, b, [msg] )
Assert.IsEqual( a, b, [msg] )
Assert.NotEqual( a, b, [msg] )
Assert.NotEquals( a, b, [msg] )
Assert.IsNotEqual( a, b, [msg] )
Assert.IsNothing( obj, [msg] )
Assert.IsNull( obj, [msg] )
Log if the obj is not nothing.
Assert.IsNotNull( obj, [msg] )
Assert.IsSomething( obj, [msg] )
Log if the obj is null.
Assert.ExpectError [errormsg]
Assert.Failure( [msg] )
Assert.Error( [msg] )
Reports an error to the framework.

todo

  • テストを書いてみる。

参考文献

Side-by-Side Manifest Contents - Complete Example ( http://www.mazecomputer.com/sxs/help/inside2.htm )
manifest ファイルの例を掲載されています。
Windows XP で分離アプリケーションと Side-by-Side アセンブリをビルドし、サービスを提供する方法 ( http://www.microsoft.com/japan/msdn/windows/window... )
ベンダが公開している Windows XP における Side-by-Side 利用のための手引き。
アプリケーションで共有する Side-by-Side コンポーネントの実装 (拡張) ( http://www.microsoft.com/japan/msdn/windows/window... )
ベンダが公開している、 Windows 98se および Windows 2000 に実装された Side-by-Side 技術利用のための手引き。

更新履歴


2007/5/12sat ページ作成。

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

Wiki内検索

編集にはIDが必要です