Таблица примеров набросков сценария Specflow - объект? - PullRequest
0 голосов
/ 04 февраля 2019

Я использую specflow, и в моих примерах у меня довольно большая таблица:

, в ней около 14 полей.

есть ли лучший способ передать все эти поля в метод item1, item2 и item4

Я вижу, что существует метод создания набора, но это не похожечтобы удовлетворить примеры, и только в шаге .... хорошо шаги.

есть ли способ передать данные в объект, а не отправлять 14 строк?

Надеюсь, что имеет смысл.

Та,

Стив

** Редактировать ** добавление примера Вот заголовки для моего файла exmaple | propLocation | locPropToBuy | propertyType | newBuild | appsLiveProprty | ownershipType | purchPrice | totLoanAmount | intOnlyAmount | prefLoanTermYrs | prefLoanTermMths |

метод, сгенерированный дляэто будет выглядеть так:

[When(@"the user provides input for the Property and Loan Requirements Section (.*) and (.*) and (.*) and (.*) and (.*) and (.*) and (.*) and (.*) and (.*) and (.*) and (.*) and (.*) and (.*) and (.*) and (.*)")] public void WhenTheUserProvidesInputForThePropertyAndLoanRequirementsSectionEnglandAndYesAndTerracedHouseAndYesAndYesAndStandardAndAndAndAndAndAndAndAndSAnd(string propLocation, string locPropToBuy, string propertyType, string newBuild, string legalOwnership, string ownershipType, string equityShreScheme, string purchPrice, string fullMarketVal, string termShareLoanYrs, string termShareLoanMths, string totLoanAmount, string intOnlyAmount, string prefLoanTermYrs, string prefLoanTermMths)

Хотя я в конечном итоге изменит кодированные значения на (. *) и т. д.

Мне было бы легче, если бы яможет просто передать объект или список всех значений, а не длинные экземпляры строк.

1 Ответ

0 голосов
/ 15 февраля 2019

Взгляните на таблицы Specflow

When the user provides input for the Property and Loan Requirements Section
| Key         | Value      |
| propLocation| NYC        |
| locPropToBuy| House123   |
| propertyType| House      |
| newBuild    | Nope       |

и т. Д. И т. П.

Создайте новый класс с помощью PropertyLoanData и затем интерпретируйте таблицу

    public class PropertyLoanData
    {
      public string propLocation { get; set; }
      public string locPropToBuy { get; set; }
      public string propertyType { get; set; }
      public string newBuild     { get; set; }
    }

.

   [When(@"the user provides input for the Property and Loan Requirements Section
    public void WhenUserprovidesinputforPropertyAndLoanSection(Table table)
    {
        var proploandata = table.CreateInstance<PropertyLoanData>();
        driver.FindElement(By.Id("propLocation")).SendKeys(proploandata.propLocation);
        driver.FindElement(By.Id("locPropToBuy")).SendKeys(proploandata.locPropToBuy);
        driver.FindElement(By.Id("propertyType")).SendKeys(proploandata.propertyType);
        driver.FindElement(By.Id("newBuild")).SendKeys(proploandata.newBuild);
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...