6/13
Peli's Blogより
Reflector Graph v1.2 released
アセンブリの参照関係をグラフ化したりするReflector用プラグインですが、ユニットテストのひな形を作る機能が追加されたようです。
例えば、次のようなアセンブリに対してツールを使うと、
using System; namespace ClassLibrary { public class Calc { public static int Multiply(int a, int b) { return a * b; } public static int Divide(int a, int b) { if (b == 0) throw new DivideByZeroException(); return a / b; } } }
こんなテストコードが生成されます。
namespace ClassLibrary4 { using System; /// <summary>Test fixture for the <see cref="Calc"/> class</summary> /// <remarks /> [TestFixture()] public class CalcTest { /// <summary /> /// <remarks /> private Calc _calc = null; /// <summary /> /// <remarks /> public virtual Calc Calc { get { return this._calc; } } /// <summary>Tests the Multiply method</summary> /// <remarks> /// <para>Target path:</para> /// <code>[ [L0000: ldarg.0] ] /// [ [L0001: ldarg.1] ] /// [ [L0002: mul] ] /// [ [L0003: stloc.0] ] /// [ [L0004: br.s 6] ] /// [ [L0006: ldloc.0] ] /// [ [L0007: ret] ] /// </code> /// </remarks> [Test()] [Ignore()] public virtual void Multiply0() { throw new System.NotImplementedException(); } /// <summary>Tests the Divide method</summary> /// <remarks> /// <para>Target path:</para> /// <code>[ [L0000: ldarg.1] ] /// [ [L0001: brtrue.s 9] ] /// L0003: newobj DivideByZeroException..ctor() : Void /// L0008: throw /// [ [L0009: ldarg.0] ] /// [ [L000A: ldarg.1] ] /// [ [L000B: div] ] /// [ [L000C: stloc.0] ] /// [ [L000D: br.s 15] ] /// [ [L000F: ldloc.0] ] /// [ [L0010: ret] ] /// </code> /// </remarks> [Test()] [Ignore()] public virtual void Divide0() { throw new System.NotImplementedException(); } /// <summary>Tests the Divide method</summary> /// <remarks> /// <para>Target path:</para> /// <code>[ [L0000: ldarg.1] ] /// [ [L0001: brtrue.s 9] ] /// [ [L0003: newobj DivideByZeroException..ctor() : Void] ] /// [ [L0008: throw] ] /// L0009: ldarg.0 /// L000A: ldarg.1 /// L000B: div /// L000C: stloc.0 /// L000D: br.s 15 /// L000F: ldloc.0 /// L0010: ret /// </code> /// </remarks> [Test()] [Ignore()] public virtual void Divide1() { throw new System.NotImplementedException(); } /// <summary>Tests the .ctor method</summary> /// <remarks> /// <para>Target path:</para> /// <code>[ [L0000: ldarg.0] ] /// [ [L0001: call Object..ctor() : Void] ] /// [ [L0006: ret] ] /// </code> /// </remarks> [Test()] [Ignore()] public virtual void Constructor0() { throw new System.NotImplementedException(); } /// <summary>Sets up the fixture</summary> /// <remarks /> [SetUp()] public virtual void SetUp() { throw new System.NotImplementedException(); } /// <summary>Releases resource allocated in the fixture</summary> /// <remarks /> [TearDown()] public virtual void TearDown() { throw new System.NotImplementedException(); } } }
ちょっと面白いかも。