Posts

Automation testing in Postman

Image
 Common API status code: 1. 200 - request was successful 2. 201 - record has been created successfully 3. 204 - no content  4. 400 - bad request 5. 401 - unauthorised 6. 403 - forbidden 7. 404 - not found 8. 429 - too many request 9. 500 - server error 10. 501 - internal server error 11. 503 - time out ------------- In postman, we can use the snippet packages written in javascript such as below: Below is a sample of how to run an automation test in Postman for API testing This will be checking the specific value of a variable Creating, storing and using a variable in Postman storing in an environment invoking the variable in a different API (must select the correct environment) Checking the first returned id data: If need to run the full collection: Test result:

API & Webservice

Image
  Difference between webservice and API - All webservice are APIs - APIs might not be a webservice Examples of API terms POST: create a record GET: read or view a single or multiple records PUT: update an existing record DELETE: delete an existing record Can use below site for testing: Reqres - A hosted REST-API ready to respond to your AJAX requests

XPath, Test data variables on Specflow

Image
 XPath is not a very reliable element to use for automation especially in start up projects as there would be a lot of changes. (e.g. if developer change the position of the element) XPath syntax: Example of self-written XPath: Example 2: A more stable way to create XPath: Good practice for recognizing element: 1. Always use ID if available as they are unique 2. Name 3. Class - if class is unique 4. use text 5. copy paste XPath ------------- Test Data variables on Specflow: *There must be method that could check and assert the variables here.

Specflow Pt2, using different test data

Image
  In the step definition, just input the codes respectively. string here indicates that this method will return a string value. If void would mean that there is no value to be returned. This will be the validation and testing portion for specflow Description here will be a variable. All data below Description are the test data to be used during testing. Underlined in red would be a dynamic value. Underlined in yellow is the variable parameter. EditTM method needs to be updated to accept a description parameter.

Specflow, Gherkin

Image
 Specflow is a BDD framework - purpose of using Specflow is when you want to apply BDD methodology (because Selenium is not enough to implement BDD) BDD Behavior-driven development (BDD) is an agile software development methodology that  focuses on collaboration and communication between developers, testers, and business stakeholders Selenium is also a framework NUnit is also a framework In feature file part, will use Gherkin syntax to write test case (will only include human language test case) Step definition will bridge the human language with the code To use Specflow, need to install below NuGet packages Creating a feature file: Folder > Add > New Item > Specflow The tag can be used to tag the test case. Example, @positive / @smoke / @regression etc What is Gherkin ? Given, When, Then - These are Gherkin syntax Creating the step definition:

IAlert, Flaky test, Tear Down, parallelizable

Image
  To accept an alert: ----- Flaky test - means a code that fails to produce the same result each time Tear Down: To make independent tests able to be run parallelly

Unit Testing - NUnit, assertions, exception handling

Image
 Why unit test is useful? Example if we have 100 tests, and you just want to run test number 25 and 40. This is where you can make use of unit test. What is a unit test? Unit test is essentially a framework. A framework is a pre-defined structure that provides a starting point for building software.  It includes reusable code modules, libraries, compilers, and other components There are many frameworks to do unit testing such as Nunit, Xunit etc. What is a design pattern? Design pattern is how you structure your tests. How your code is presented in your solution. Example, you have test class, and then pages and codes are inside the pages etc.  NUnit Annotations: - SetUp - Test - TearDown - TestFixture Not commonly used: - OneTimeSetUp - OneTimeTearDown NuGet Packages Microsoft.NETCore.App is the package that allows to run tests as a dot net core application. This is essentially a framework. For NUnit testing, to install below NuGet packages: NUnit package allows us to use...