簡體   English   中英

我無法從另一個文件調用方法到主項目文件來運行我的測試用例

[英]I am not able to call method from another file to main project file to run my test case

我打開了預先存在的excel文件並將其刪除。 但它不會被刪除。 我怎樣才能做到這一點?

您的代碼不起作用,因為如果您不提供該參數,則無法調用已使用一個字符串 List 參數聲明的方法。

public void exceldownload(List<string> lst)

我不確定我是否完全理解您的所有代碼,但是您可以通過兩種方式解決此問題:

  1. 首先,您可以將 list 參數提供給 exceldownload 函數,如下所示:

     public void Excel() { Program a = new Program(); a.exceldownload(new List<string>()); //or you can add in the list that you want to contain }
  2. 您可以更改 exceldownload 函數的定義,以便通過使用可選參數不接受任何參數:

     public void exceldownload(List<string> lst = null) { if(lst == null) { //TODO: manage this null as it should be } string str; int rw = 0; int cl = 0;

希望能幫到你

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM