我無法執行拆解,該拆解應該洗掉我的自動化在我們的應用程式上創建的所有帳戶。我選擇使用 OneTimeTearDown 所以它執行一次并且只是通過串列但它似乎沒有執行。這是代碼,我可能把它放在錯誤的地方嗎?如果我只是將其添加到測驗的末尾,則拆解中的代碼可以自行作業。
命名空間 Ag.AutomatedRegression.UI.Tests.AccountsTests
{
[測驗夾具]
公共類 AccountsPageTests : BaseSetup
{
[一次性拆解]
公共無效CleanUpAccounts()
{
LogList.Add($"輸入了 {MethodBase.GetCurrentMethod()}()。");
for (int i = AccountsPageTests.accountIdList.Count - 1; i >= 0; i--)
{
如果(AccountsPageTests.accountIdList.Count == 0)
{
LogList.Add("串列中沒有要洗掉的 id。");
休息;
}
別的
{
LogList.Add("下一步:清理創建此會話的帳戶。");
PerformBrowserManagerAction.NavigateToURL(CommonSettings.Default.URL);
PerformCommonStagesAction.CleanUpAccounts(CommonSettings.Default.UserName,
CommonSettings.Default.EncryptedPassword,
AccountsPageTests.accountIdList[i]);
}
LogList.Add("賬戶清理成功。");
}
}
公共靜態串列 accountIdList = new List();
[測驗]
公共無效 CreateAccountTest()
{
LogList.Add($"輸入了 {MethodBase.GetCurrentMethod()}()。");
//使用帳戶ID字串變數創建帳戶的代碼
Assert.That(Success, Is.True, expectedMessage "\r\n"
實際訊息);
}
}
}
uj5u.com熱心網友回復:
您的宣告中的索引
for (int i = AccountsPageTests.accountIdList.Count - 1; i > 0; i--)
不做你想做的事。它永遠不會處理串列項 0,如果只有 1 項,則不會顯示任何內容。
假設有一個專案,在腦海中逐步完成
- 計數 - 1 為 0
- 0 不大于 0
- 所以沒有專案被執行
改變i > 0' to i >= 0`
uj5u.com熱心網友回復:
正如我們已經在評論中討論的那樣,請嘗試格式化是否是您班級的問題:
using NUnit.Framework;
namespace Your.Tests
{
[TestFixture]
public class AccountsPageTests : BaseSetup
{
private List<string> accountIdList = new List<string>();
[OneTimeTearDown]
public void CleanUpAccounts()
{
LogList.Add($"Entered the {MethodBase.GetCurrentMethod()}().");
for (int i = AccountsPageTests.accountIdList.Count - 1; i >= 0; i--)
{
if (AccountsPageTests.accountIdList.Count == 0)
{
LogList.Add("There were no ids in the list to delete.");
break;
}
else
{
LogList.Add("Next Step: Clean Up accounts created this session.");
PerformBrowserManagerAction.NavigateToURL(CommonSettings.Default.StagesURL);
PerformCommonAction.CleanUpAccounts(CommonSettings.Default.StagesUserName,
CommonSettings.Default.StagesEncryptedPassword,
AccountsPageTests.accountIdList[i]);
}
LogList.Add("Account Cleanup was successful.");
}
}
[Test]
public void CreateAccountTest()
{
LogList.Add($"Entered the {MethodBase.GetCurrentMethod()}().");
//Code to Create account with accountId as a string
accountIdList.Add(accountId);
}
}
}
uj5u.com熱心網友回復:
在 mu88 的回答之后,格式是正確的,但這并沒有解決拆解問題,我最終將其改為標準拆解,這似乎已經解決了這個問題。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/492639.html
