Saturday 30 January 2021

How to Create fake REST API using Json-server and use from Postman to perform API Testing?

 


 Check below link for interview Q&A  API TESTING:
 


Fake REST APIs created using JSON Server are essential for testing purposes. They offer a valuable means of independently testing frontend applications without relying on a fully developed or available backend server. 


By defining custom routes and responses in a JSON file, developers can simulate different server responses, including success, error, and edge cases, to ensure proper handling by the frontend. These fake APIs enable the reproduction of specific scenarios that may be difficult to replicate with a real backend, such as slow network connections or specific error conditions. 


Moreover, they facilitate rapid prototyping, allowing frontend developers to start building user interfaces and interact with simulated data without waiting for the complete backend functionality. Fake REST APIs also serve to test edge cases, providing a controlled environment for assessing how the application handles unusual scenarios and ensuring optimal performance. 


Ultimately, the use of fake REST APIs with JSON Server enhances testing efficiency, isolates the testing environment, and enables comprehensive evaluation of frontend applications.

JSON Server is a simple project that helps you to setup a REST API with CRUD operations very fast. So let's learn how we can create fake rest api using json-server, It is useful for building frontend apps and for testing integration components. 

Step-1:
Download node js, refer below link:
https://nodejs.org/en/download/

Open a command prompt (or PowerShell), and enter the following:

node –v

The system should display the Node.js version installed on your system. You can do the same for NPM:

npm –v

For above two commands you should get response as below :


C:\Users>node -v
v10.16.3

C:\Users>npm -v
6.9.0



Step:2

npm install -g json-server

***************************

 DevOps Interview Question Set

***************************

Step-3

Create a json file as db.json and open cmd in that path
Define the json format:
{
  "employees": [
    {
      "id": 1,
      "first_name": "sidharth",
      "last_name": "shukla",
      "email": "sidharth@automationreinvented.com"
    },
    {
      "id": 2,
      "first_name": "Steve",
      "last_name": "smith",
      "email": "steve@automationreinvented.com"
    },
    {
      "id": 3,
      "first_name": "virat",
      "last_name": "kohli",
      "email": "virat@automationreinvented.com"
    }
  ]
}

Step-04:

Run the below command from command prompt
json-server --watch db.json


Step-05:

By Default it will take localhost:3000, Now we can open URL http://localhost:3000/employees in the browser

*************************************************

Framework Design Tips & Interview Question-Click Here

********************************************

Step-06:
How to test in Postman?


Just open postman tool and ru below URI:


It's possible to extend URLs with further parameter. E.g. you can apply filtering by using URL parameters like you can see in the following:


http://localhost:3000/employees?last_name=shukla
http://localhost:3000/employees?first_name=sidharth
http://localhost:3000/employees/1

Validate the status code and response body.

Automation Testing/SDET Framework Design Link

Java Related Interview Question Set LINK

GIT Interview Question Set LINK

Step-07:

The following HTTP endpoints are created automatically by JSON server:


GET    /employees
GET    /employees/{id}
POST   /employees
PUT    /employees/{id}
PATCH  /employees/{id} 

So all the above methods can be tested both from Postman or Rest Assured.

NOTE: Learn (API-Microservice)Testing+(CoreJava+UI)-SDET with Self Paced Videos and one LIVE Doubt Session with the Author of this blog who is working as an SDET @ Amazon.

*******************************************************************
For any doubts or career guidance from me, reach out here : https://topmate.io/sidharth_shukla

********************************************************************

Do remember that knowing Linux is one of the most important aspect to work as an SDET.

Basic Linux Commands for Automation QA


****************************************


SELF PACED TRANING VIDEOS AVAILABLE with Doubt Session @4500/-(API+Postman+RestAssured+Framework+GIT+Jenkins+Project+DoubtSession(1-1)) and 6500/- (API+UI) Check Training Page for Course Content or reach out @whatsapp +91-9619094122




***********************************************************

************************************************* 

  • Explain testNG annotation in sequence with real time scenario?example of @After@Before in TestNG?selenium interview qus/testng

Click Here For Answer

*************************************************

SeleniumWebdriver Automation Testing Interview Questions:

API Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Rest-API

 
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes

 
Docker Interview Question Set
https://automationreinvented.blogspot.com/2020/02/top-18-docker-commands-for-aytomation.html

 
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux

 
Automation Testing/SDET Framework Design
https://automationreinvented.blogspot.com/search/label/FrameworkDesign


Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java


GIT Interview Question Set:
https://automationreinvented.blogspot.com/search/label/GIT


Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions

 

Sunday 24 January 2021

How to generate random string for test data in Automation Framework?


  • How to generate Random String for test data?

    In the below code return type is String and input parameter is integer(int length)

//generate random alphabet string

public static String generateRandomString(int length) {

        String text ="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
                StringBuilder sb = new StringBuilder(length);
        for( int i = 0; i < length; i++ )
            sb.append( text.charAt( random.nextInt(text.length()) ) );
        return sb.toString();

    }

//generate random integer string

    public static String generateRandomNumericString(int length) {
        String textnumber ="0123456789";
        StringBuilder sb = new StringBuilder(length);
        for( int i = 0; i < length; i++ )
            sb.append( textnumber.charAt( random.nextInt(textnumber.length()) ) );
        return sb.toString();//build

    }

More Framework Design related code?

https://automationreinvented.blogspot.com/search/label/FrameworkDesign

  • How to call above methods to generate the string and save in a variable ?

Generate random string of length 5?

String job = RandomUtils.generateRandomString(5);//generateRandomString = method we have created as above

Generate random numeric string of length 8?

String name = RandomUtils.generateRandomNumericString(8);//generateRandomNumericString= method we have created as above

 

************************************************* 

  • Explain testNG annotation in sequence with real time scenario?example of @After@Before in TestNG?selenium interview qus/testng

Click Here For Answer

**************************************************

SeleniumWebdriver Automation Testing Interview Questions:

API Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Rest-API

 
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes

 
Docker Interview Question Set
https://automationreinvented.blogspot.com/2020/02/top-18-docker-commands-for-aytomation.html

 
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux

 
Automation Testing/SDET Framework Design
https://automationreinvented.blogspot.com/search/label/FrameworkDesign


Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java


GIT Interview Question Set:
https://automationreinvented.blogspot.com/search/label/GIT


Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions

Saturday 16 January 2021

Top 70 interview questions on Automation Testing-Selenium-TestNG Set-06? TestNG Tricky Interview questions 2021 for SDET-QAE?

 

 

Check Selenium Interviewquestions from 1 to 10 below:


Check Selenium-SDET-UIAutomation Questions set 11 to 20:
Qus Set - 11 to 20

Check Selenium-SDET-UIAutomation Questions set 21 to 30:
 
Check Selenium-SDET-UIAutomation Questions set 31 to 40:

 Question Set 31-40  

Check Selenium-SDET-UIAutomation Questions set 41-50:

Q&A Set 41-50

 Below is the list of most important attributes for TestNG annotations, in terms of day to day work and interview preparation

  • Description:    The description for this method.

If we are writing test script to validate 200 status code for /users get method then below is the description:

@Test(description="Validate 200 status code for /users GET API")

  • Enabled:    Whether methods on this class/method are enabled.

@Test(description="B_Users:Validate 200 status code for /users GET API", enabled=false)

As mentioned above, if we mark a test case enabled=false, then this test case will be skipped while execution.

  • alwaysRun:    If set to true, this test method will always be run even if it depends on a method that failed.

Ans: @Test(description="Validate 200 status code for /users GET API",alwaysRun=true)

  • HOW to Rerun failed test cases of your automation suite using Listeners?


       Ans: Click Here For Answer with code

  • priority:    The priority for this test method. Lower priorities will be scheduled first.

Ans: @Test(description="B_Users:Validate 200 status code for /users GET API", priority=1)

  • What is the default priority in testng?

       Ans: Based on ASCII value

  • Can priority be negative or zero value?

           Yes

  • groups:    The list of groups this class/method belongs to?

    @Test(description="Verify email for User with id=2",groups= {"SomkeSuite","RegressionSuite"})
    @Test(description="Verify status code for GET method-users/2 as 200",groups="SmokeSuite")

  • Explain some of the Advanced TestNG annotations?

CLICK HERE FOR ANSWER

  • Execute test cases from class payment?//payment is class name

<suite name="API Automation Smoke Suite">
    <test name="Automation Test Cases">
        <classes>
              <class name="<nameofthepackage>.payment"/>
        </classes>
   </test>
</suite>

  • Execute multiple classes from a package using testng xml suite?


<suite name="API Automation Smoke Suite">
    <test name="Automation Test Cases">
        <classes>
              <class name="apiautomationeleven.test"/>
              <class name="apiautomationeleven.registration"/>
              <class name="apiautomationeleven.payment"/>
        </classes>
   </test>
</suite>

  • Explain testNG annotation in sequence with real time scenario?example of @After@Before in TestNG?selenium interview qus/testng

      Click Here For Answer

  • Execute all classes from a pckage using testng.xml suite?


<suite name="API Automation Smoke Suite">
    <test name="Automation Test Cases">
        <packages>
           <package name="apiAutomationeleven" />
        </packages>
   </test>
</suite>

  • How to run automation suites with groups?


<suite name="API Automation Smoke Suite">
    <test name="Automation Test Cases">
        <groups>
           <run>
             <exclude name="brokenTests"  />
             <include name="SmokeSuite"  />
           </run>
        </groups>
   </test>
</suite>

  • How to use dependsOnGroups?


@Test(description="B_Users:Validate 200 status code for /users GET API",dependsOnGroups="Auth_OAUTH")

  • How to run test automation TestNG suite with gradle from jenkins job? Jenkins Integration with Gradle and TestNG.xml suite?Run TestNG suite with Gradle?

    Ans:
    Click Here For Answer With Screenshot

  • How you can specify your group dependencies in the testng.xml file. You use the <dependencies> tag to achieve this


<suite name="API Automation Smoke Suite">
    <test name="Automation Test Cases">
        <dependencies>
          <group name="B_User" depends-on="Auth_Oauth" />
        </dependencies>
   </test>
</suite>

  • How to use @Parameters in TestNG?


@Parameters({ "first-name" })
@Test
public void testSingleString(String firstName) {
  System.out.println("Invoked testString " + firstName);
  assert "Cedric".equals(firstName);
}



Learn (API-Microservice)Testing+(CoreJava+UI)-SDET with Self Paced Videos and one LIVE Doubt Session

TRANING VIDEOS AVAILABLE with Live Doubt Session @4500/-(course-1 below,API TRaining Videos With ClassNotes and Coding Set) and 6500/- (API+UI, both course-1 & 2 below) Check Training Page for Course Content or reach out @whatsapp +91-9619094122

Entire course content can be found below:  COURSE CONTENTCheck below link for question and answers with code:

 API Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Rest-API

SeleniumWebdriver Automation Testing Interview Questions:

 
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes

 
Docker Interview Question Set
https://automationreinvented.blogspot.com/2020/02/top-18-docker-commands-for-aytomation.html

 
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux

 
Automation Testing/SDET Framework Design
https://automationreinvented.blogspot.com/search/label/FrameworkDesign


Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java


GIT Interview Question Set:
https://automationreinvented.blogspot.com/search/label/GIT


Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions

Friday 8 January 2021

Top 50 Linux Commands for SDET/Software QA and DevOps Interview question Set - 04? Linux Commands for Admin Profile 2021?


"Linux FUN FACTS"100% of the world’s 500 fastest supercomputers run Linux.

Let's learn Linux commands for SDET/QA/DevOps profile, do check previous posts with 40+ Linux commands and make your own cheat sheet with the entire list.
Happy Learning!

  Linux Commands Set-01 for SDET/DevOps INterview Questions

  Linux Commands Set-02 for SDET/DevOps

Linux Commands set-03 for SDET/DevOps Interview Questions

 45. Cron- set up scheduled tasks to run.
want to know more about cron job with examples: https://en.wikipedia.org/wiki/Cron#CRON_expression

46. nmcli – network management.
47. ping – send ICMP ECHO_REQUEST to network hosts.
48. traceroute Click Here For Answer
49. mtr – network diagnostic tool.
50. nslookup 
Click Here For Answer
51. host – perform DNS lookups in Linux.

Top 21 GIT interview questions: Click Here

 
52.
fdisk Click Here For Answer
53. wget – retrieve files over HTTP, HTTPS, FTP, and FTPS.
54. curl – transferring data using various network protocols. (supports more protocols than wget)

Know About DevOps-Click Here

 
55. dd – convert and copy files.
56. 
nc Click Here For Answer
57. 
parted – for creating and manipulating partition tables.

Top Kubernetes Commands-Click Here

 
58. blkid – command-line utility to locate/print block device attributes.
59. mkfs – build a Linux file system.
60. fsck – 
Click Here For Answer

  • What is Kali Linux:

Kali Linux is a Debian-based Linux distribution aimed at advanced Penetration Testing and Security Auditing. Kali Linux was released on the 13th March 2013 as a complete, top-to-bottom rebuild of BackTrack Linux, adhering completely to Debian development standards.
Refer the link to learn more on Kali Linux: https://www.kali.org/docs/introduction/what-is-kali-linux

  • ncdu – a disk utility for Unix systems.
  • touch – used to update the access date and/or modification date of a computer file or directory.

                                           

Linux Commands Set-01 for SDET/DevOps INterview Questions

  Linux Commands Set-02 for SDET/DevOps

Linux Commands set-03 for SDET/DevOps Interview Questions

 

What is LILO in Linux?

LILO (Linux Loader) is basically a bootloader for Linux that is used to load Linux into memory and start the OS. It is also known as a boot manager that facilitates a dual boot of a computer. It can function as either a master boot program or secondary boot program and performs various functions such as locating kernel, identifying other supporting programs, loading memory, and starting the kernel. If you want to use Linux OS, then you need to install a special bootloader i.e., LILO for it as it allows fast boot of Linux OS.

Python Interview Question Set for QAE - SDET - SDE:
https://automationreinvented.blogspot.com/search/label/Python

 API Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Rest-API

 
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes

 
Docker Interview Question Set
https://automationreinvented.blogspot.com/2020/02/top-18-docker-commands-for-aytomation.html

 
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux

 
Automation Testing/SDET Framework Design
https://automationreinvented.blogspot.com/search/label/FrameworkDesign


Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java


GIT Interview Question Set:
https://automationreinvented.blogspot.com/search/label/GIT


Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions

All Time Popular Posts

Most Featured Post

API Status Codes with examples for QA-Testers

  🔺 LinkedIn: https://www.linkedin.com/in/sidharth-shukla-77b53145/ 🔺 Telegram Group:  https://t.me/+FTf_NPb--GQ2ODhl 🏮In API testing, it...