0

各ステップの後に結果を Excel ファイルに保存する C# で開発されたアプリケーション テスト フレームワークがあります。ソリューション内で実行すると、すべて正常に動作します。しかし、ソリューションを Fitnesse と統合してメソッドを呼び出すと、エラーがスローされます。フィットネスからのスタック トレースを以下に追加しました。

コード セグメントは次のとおりです。

public class ExcelReports : IReporter
{
    private Excel.Application xlReport;
    public ExcelReports()
    {
        xlReport = new Excel.Application();
        Excel.Workbook xlWorkbook = xlReport.Workbooks.Add();
        ***xlWorkbook.SaveAs(ExecutionContext.RESULTFILE);***
    }
  }

エラーは xlWorkbook.SaveAs(ExecutionContext.RESULTFILE) で報告されます

私は .NET 4.0 リリース用の fit および fitsharp dll を使用しています。

    System.Reflection.TargetInvocationException: Exception has been thrown by the
    target of an invocation. ---> System.Reflection.TargetInvocationException:
    Exception has been thrown by the target of an invocation. --->
    System.Runtime.InteropServices.COMException: Microsoft Excel cannot access the file
   'C:\0452CB00'. There are several possible reasons:
    • The file name or path does not exist.
    • The file is being used by another program.
    • The workbook you are trying to save has the same name as a currently open 
    workbook.
    at Microsoft.Office.Interop.Excel._Workbook.SaveAs(Object Filename, Object    
    FileFormat, Object Password, Object WriteResPassword, Object ReadOnlyRecommended, 
    Object CreateBackup, XlSaveAsAccessMode AccessMode, Object ConflictResolution, 
    Object AddToMru, Object TextCodepage, Object TextVisualLayout, Object Local)
    at EF.UIAutomation.Commons.ExcelReports..ctor() in
           C:\EF.Automation\EF.UIAutomation.PageLibrary\Libraries\EF.UIAutomation.Commons.Reports.cs:l ine 25

    at EF.UIAutomation.Launcher.Program.Test() in
    C:\EF.Automation\EF.Automation\Program.cs:line 26

     --- End of inner exception stack trace ---
     at fitSharp.Machine.Model.TypedValue.ThrowExceptionIfNotValid()
     at fitSharp.Fit.Operators.CompareDefault.Compare(TypedValue actualValue, Tree`1
     expected)
     at fitSharp.Machine.Engine.ProcessorBase`2.<>c__DisplayClass3.
     <>c__DisplayClass5.b__2(CompareOperator`1 o)

     at fitSharp.Machine.Engine.Operators`2.Do[O](CanDoOperation`1 canDoOperation, 
     DoOperation`1 doOperation)
     at fitSharp.Machine.Engine.ProcessorBase`2.
     <>c__DisplayClass3.b__0(OperationLogging logging)
     at fitSharp.Machine.Engine.ProcessorBase`2.DoLoggedOperation[R](String
     startMessage, Func`2 operation)
     at fitSharp.Machine.Engine.ProcessorBase`2.Compare(TypedValue instance, Tree`1
     parameters)
     at fitSharp.Fit.Operators.CheckDefault.Check(CellOperationValue actualValue, 
     Tree`1 expectedCell)
     --- End of inner exception stack trace ---
     at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, 
     Signature sig, Boolean constructor)
     at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[]
     parameters, Object[] arguments)
     at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, 
     Binder binder, Object[] parameters, CultureInfo culture)
     at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder
     binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers,
     CultureInfo culture, String[] namedParams)
     at fitSharp.Machine.Engine.MethodMember.TryInvoke(Object[] parameters)
     at fitSharp.Machine.Engine.ReflectionMember.Invoke(Object[] parameters)
     at fitSharp.Machine.Engine.ProcessorBase`2.Operate[O](Object[] parameters)
     at fitSharp.Fit.Engine.CellProcessorExtension.Check(CellProcessor processor, 
     Object systemUnderTest, Tree`1 memberName, Tree`1 parameters, Tree`1 expectedCell)
     at fitSharp.Fit.Service.CheckBinding.Do(Tree`1 cell)
     at fitSharp.Fit.Service.Binding.Do(Tree`1 cell)
     at fit.ColumnFixture.DoCell(Parse cell, Int32 column)
4

0 に答える 0