vendredi 4 mai 2018

SpecFlow API Testing

Okay so I'm really new to SpecFlow I have an API method GetPlayerInfo(string email) That when supplied with an email it returns player information in json. I'm struggling to figure out how to test this. This is what I have so far.

Feature: Get Players Data
As a developer, I want to be able to login through the API so I 
can get my player's data from a previously registered account.

Scenario: Email should be matched
    Given I use API method GetPlayerInfo(string email)
    When the email 'hm@mail.wou.edu' is entered 
    Then PlayerID should be returned as '1'

And this is what SpecFlow auto generated

namespace Test
{
    using TechTalk.SpecFlow;


    [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "2.3.2.0")]
    [System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    [NUnit.Framework.TestFixtureAttribute()]
    [NUnit.Framework.DescriptionAttribute("Get Players Data")]
    public partial class GetPlayersDataFeature
    {

        private TechTalk.SpecFlow.ITestRunner testRunner;

#line 1 "SpecFlowFeature.feature"
#line hidden

        [NUnit.Framework.OneTimeSetUpAttribute()]
        public virtual void FeatureSetup()
        {
            testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner();
            TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Get Players Data", "\tAs a developer, I want to be able to login through the API so I \r\n\tcan get my pl" +
                    "ayer\'s data from a previously registered account.", ProgrammingLanguage.CSharp, ((string[])(null)));
            testRunner.OnFeatureStart(featureInfo);
        }

        [NUnit.Framework.OneTimeTearDownAttribute()]
        public virtual void FeatureTearDown()
        {
            testRunner.OnFeatureEnd();
            testRunner = null;
        }

        [NUnit.Framework.SetUpAttribute()]
        public virtual void TestInitialize()
        {
        }

        [NUnit.Framework.TearDownAttribute()]
        public virtual void ScenarioTearDown()
        {
            testRunner.OnScenarioEnd();
        }

        public virtual void ScenarioSetup(TechTalk.SpecFlow.ScenarioInfo scenarioInfo)
        {
            testRunner.OnScenarioStart(scenarioInfo);
        }

        public virtual void ScenarioCleanup()
        {
            testRunner.CollectScenarioErrors();
        }

        [NUnit.Framework.TestAttribute()]
        [NUnit.Framework.DescriptionAttribute("Email should be matched")]
        public virtual void EmailShouldBeMatched()
        {
            TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Email should be matched", ((string[])(null)));
#line 6
this.ScenarioSetup(scenarioInfo);
#line 7
 testRunner.Given("I use API method GetPlayerInfo(string email)", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
#line 8
 testRunner.When("the email \'hm@mail.wou.edu\' is entered", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 9
 testRunner.Then("PlayerID should be returned as \'1\'", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line hidden
            this.ScenarioCleanup();
        }
    }
}

My question is how do I work with this to test my API response?

Aucun commentaire:

Enregistrer un commentaire