Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • Software and Tools
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Go Premium
  • DSA
  • Practice Problems
  • C
  • C++
  • Java
  • Python
  • JavaScript
  • Data Science
  • Machine Learning
  • Courses
  • Linux
  • DevOps
  • SQL
  • Web Development
  • System Design
  • Aptitude
  • GfG Premium
Open In App
Next Article:
What is Software Testing?
Next article icon

Gray Box Testing - Software Testing

Last Updated : 22 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Gray Box Testing is a software testing technique that combines elements of the Black Box Testing technique and the White Box Testing technique. Gray box testing is also known as translucent testing or API testing. 

Objectives of Gray Box Testing:

  1. To provide the combined advantages of both black box testing and white box testing.
  2. To combine the input of developers as well as testers.
  3. To improve overall product quality.
  4. To reduce the overhead of the long process of functional and non-functional testing.
  5. To provide enough free time to developers to fix defects.
  6. To test from the user's point of view rather than a designer's point of view.

Explore the complete details of Gray Box Testing, including its techniques, advantages, and limitations, in our article. For a thorough understanding of various testing methodologies and tools, check out our course, ” Complete Guide to Software Testing,” available at GeeksforGeeks.

pp110
Gray Box Testing

Gray Box Testing Techniques

Here are the main techniques of the Gray Box Testing which are included in the gray box testing:

Gray-Box-Testing-Techniques
Gray Box Testing Techniques

1. Matrix Testing

In Matrix Testing technique, business and technical risks which are defined by the developers in software programs are examined. Developers define all the variables that exist in the program. Each of the variables has an inherent technical and business risk and can be used with varied frequencies during its life cycle.

2. Pattern Testing

To perform the pattern testing , previous defects are analyzed. It determines the cause of the failure by looking into the code. Analysis template includes reasons for the defect. This helps test cases designed as they are proactive in finding other failures before hitting production.

3. Orthogonal Array Testing

Orthogonal Array Testing is a black box testing technique. In orthogonal array testing, test data have n numbers of permutations and combinations. Orthogonal array testing is preferred when maximum coverage is required when there are very few test cases and test data is large. This is very helpful in testing complex applications.

4. Regression Testing

Regression Testing is testing the software after every change in the software to make sure that the changes or the new functionalities are not affecting the existing functioning of the system. Regression testing is also carried out to ensure that fixing any defect has not impacted other functionality of the software.

5. State transition Testing

State Transition Testing is frequently applied to systems that display various states while they are being operated. Testers who have just a limited understanding of the internal states create test cases with the intention of making sure that state transitions are handled correctly.

6. Testing Decision Tables

Decision tables are a useful tool for organizing and condensing complicated business rules and reasoning. Decision tables are used by testers with limited understanding to generate test cases covering multiple combinations of input conditions and expected results.

7. Testing APIs

Even though the main code is not entirely known, gray box testing, also known as API (Application Programming Interface) Testing , focuses on testing the system’s exposed interfaces. The main goal of testing is to make sure the API accepts various input formats and operates as intended.

8. Data Flow Testing

Analyzing the Flow of Data Testing through the system forms the basis of data flow testing. Partial knowledge testers create test cases that examine the data’s pathways throughout the application, assisting in the identification of possible problems with handling and processing the data.

Process of Gray Box Testing

Gray box testing mix the both black box and white box testing. The tester has partial knowledge of how the system works internally but focuses mainly on its inputs and outputs. Unlike white box testing, you don’t need to design tests based on the code. Instead, you combine insights from both external and internal perspectives to guide the testing process.

Process of Gray Box Testing
Process of Gray Box Testing

1. Identify Inputs

First, look at the system and decide which inputs you need for testing. This can be done using black box testing (looking at the system from the outside) and white box testing (understanding some of the internal structure). By combining both, you get a clearer idea of what inputs are essential for testing the system.

2. Predict Outputs

Once you know the inputs, think about what the expected results (outputs) should be. This helps in understanding whether the system will behave as expected when given the right inputs.

3. Select Key Testing Paths

Next, focus on the most important parts of the system that need testing. Think about the key features and how they work both internally (the system’s code and structure) and externally (how users interact with the system). These are the paths you should test first.

4. Spot Sub-Functions

Look at smaller parts or features within the system that may need extra attention. These could be small components that play a big role but may get overlooked if not specifically tested.

5. Identify Inputs for Sub-Functions

Once you’ve spotted these smaller sub-functions, figure out the exact inputs that will test them properly. These inputs should be carefully chosen to make sure the sub-functions work as they should.

6. Predict Expected Outputs for Sub-Functions

After identifying the inputs for the sub-functions, predict what the output should be. This helps you understand what results you’re expecting from these smaller features when the right inputs are applied.

7. Run Sub-Function Test Cases

Now, test the sub-functions by applying real-world inputs and conditions. You’ll want to see if these sub-functions handle the inputs correctly and behave as expected in real scenarios.

8. Verify the Results

Once the tests are run, compare the actual results to the expected outputs. If the actual results match the predicted ones, that means everything is working as it should. If not, you can identify where things went wrong.

9. Repeat Steps 4-8

Testing not stop after doing one time only, test other sub-functions and paths that may not have been fully tested the first time. This ensures every part of the system is well-tested.

10. Refine and Repeat

After testing, you may find some issues or areas that need improvement. Keep refining your test cases, test again, and keep adjusting based on the results. This ensures the system is thoroughly tested and works as expected.

Grey Box Testing Example

To better understand how gray box testing works by combining elements of both white box and black box testing, let’s take an example of a User Registration System.

ArtOfTesting's login functionality include gray box testing and the user interface (UI) and the backend systems are functioning as expected. This type of testing combines knowledge of the system’s internal workings (like the API, database, and user authentication logic) with external user-facing behavior.

Steps:

  1. Navigate to the Login Page: Open the login page URL using Selenium.
  2. Fill in Username: Enter a valid username (e.g., auth_user) into the username field.
  3. Fill in Password: Enter the correct password (e.g., auth_password) into the password field.
  4. Click on Login Button: Simulate a click on the login button.
  5. Verify Successful Login: Ensure that the user is redirected to the correct page after logging in.
  6. Database Check (Optional): Check the database to ensure that the login attempt was recorded in the user login table.
  7. API Verification (Optional): Verify the login API response to ensure it returns the correct status and session information.

BaseTestMain.java

Java
package Test;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;

public class BaseTestMain {

    protected WebDriver driver;
    protected String Url = "https://ecommerce.artoftesting.com/";

    // Set up the ChromeDriver
    @BeforeMethod
    public void setup() {
        // Set the path to your chromedriver executable
        System.setProperty("webdriver.chrome.driver", "C:\\Users\\path of the chromedriver\\drivers\\chromedriver.exe");
        
        
        // Initialize the ChromeDriver
        driver = new ChromeDriver();
    }

    // Close the browser after each test
    @AfterMethod
    public void teardown() {
        if (driver != null) {
            driver.quit();
        }
    }
}

LoginPage.java

Java
package ArtOfTesting;

import org.openqa.selenium.By;
import org.testng.Assert;
import org.testng.annotations.Test;

import Test.BaseTestMain;

public class LoginPageTest extends BaseTestMain{
	
	@Test
	public void TestLogin() {
		driver.get(Url);
		driver.findElement(By.name("uname")).clear();
		driver.findElement(By.name("uname")).sendKeys("auth_user");
		
		Assert.assertEquals(driver.getCurrentUrl(), "https://ecommerce.artoftesting.com/");
		
		driver.findElement(By.name("pass")).clear();
		driver.findElement(By.name("pass")).sendKeys("auth_password");
		
		driver.findElement(By.className("Login_btn__pALc8")).click();
		System.out.println("Login Succesfull");
		
		 // Optional: Backend Verification - Database Check
        // For this step, you could verify the database to ensure the login attempt was logged.
        // Example (pseudo-code for DB verification, not actual code in the test):
        // assertTrue(checkDatabaseForLoginAttempt("auth_user"));

        // Optional: API Verification - Verify API response (you can use Postman or other API testing tools for this)
        // Example (pseudo-code for API verification):
        // assertTrue(verifyLoginApiResponse("auth_user"))
		
	}

}

Output:

output-of-gray-box-test-example
Output of Gray Box Test Example

Gray Box Testing Tools

Here are the some of tools which includes in the process of gray box testing:

1. Selenium

Selenium tool automates web application tests and supports multiple browsers, making it ideal for testing web apps across different environments. It helps testers verify the functionality and user experience of web applications efficiently.

2. Appium

Appium tool is used for automating mobile application tests. Appium allows testers to test both Android and iOS apps, ensuring they function correctly across various mobile platforms.

3. Postman

Postman is widely used for API testing. It allows testers to send API requests and check the responses, making it essential for verifying the functionality and reliability of the backend of applications.

4. JUnit and NUnit

JUnit and NUnit are Unit testing frameworks for Java and .NET applications, respectively. They help in validating individual components of the code during gray box testing, ensuring specific parts of the software function as expected.

5. Burp Suite

Burp Suite is a powerful security testing tool for web applications. Burp Suite analyzes network traffic and helps identify potential vulnerabilities, making it valuable for gray box testing to ensure the application’s security.

6. Chrome DevTools

Chrome DevTools are Built-in browser tools that assist testers in inspecting web pages, debugging JavaScript, and logging network activity. They provide valuable insights into the technical performance of web applications during gray box testing.

Difference between Black Box Testing and Gray Box Testing

Gray box testing is a combination of black box and white box testing, and can provide a more comprehensive testing approach than black box testing alone. The choice of testing approach depends on the testing objectives, the testing stage, and the available resources.

Here is a simple comparison of them in which highlighting key aspects:

Black Box TestingGray Box Testing
It is a software testing technique in which the tester doesn’t know the internal structure of the application being tested.It is a software testing technique in which the tester partially know the internal structure of the application being tested.
It is known as closed box testing.It is known as translucent testing.
No knowledge of implementation is required.Knowledge of implementation is required but need not to be expert.
It is based on external expectations and outer behavior of the software.It is based on database diagrams and data flow diagrams.
It is less time consuming.It is time consuming but not too much.
Read More: Black Box Testing vs Gray Box Testing


Next Article
What is Software Testing?

P

pp_pankaj
Improve
Article Tags :
  • Software Testing
  • Software Testing

Similar Reads

    Software Testing Tutorial
    Software testing is an important part of the software development lifecycle that involves verifying and validating whether a software application works as expected. It ensures reliable, correct, secure, and high-performing software across web, mobile applications, cloud, and CI/CD pipelines in DevOp
    10 min read
    What is Software Testing?
    Software testing is an important process in the Software Development Lifecycle(SDLC). It involves verifying and validating that a Software Application is free of bugs, meets the technical requirements set by its Design and Development, and satisfies user requirements efficiently and effectively.Here
    11 min read
    Principles of Software testing - Software Testing
    Software testing is an important aspect of software development, ensuring that applications function correctly and meet user expectations. From test planning to execution, analysis and understanding these principles help testers in creating a more structured and focused approach to software testing,
    3 min read
    Software Development Life Cycle (SDLC)
    Software Development Life Cycle (SDLC) is a structured process that is used to design, develop, and test high-quality software. SDLC, or software development life cycle, is a methodology that defines the entire procedure of software development step-by-step. The goal of the SDLC life cycle model is
    8 min read
    Software Testing Life Cycle (STLC)
    The Software Testing Life Cycle (STLC) is a process that verifies whether the Software Quality meets the expectations or not. STLC is an important process that provides a simple approach to testing through the step-by-step process, which we are discussing here. Software Testing Life Cycle (STLC) is
    7 min read
    Types of Software Testing
    Software testing is a important aspect of software development life-cycle that ensures a product works correctly, meets user expectations, and is free of bugs. There are different types of software testing, each designed to validate specific aspects of an application, such as functionality, performa
    15+ min read
    Levels of Software Testing
    Software Testing is an important part of the Software Development Life Cycle which is help to verify the product is working as expected or not. In SDLC, we used different levels of testing to find bugs and errors. Here we are learning those Levels of Testing in detail.Table of ContentWhat Are the Le
    4 min read
    Test Maturity Model - Software Testing
    The Test Maturity Model (TMM) in software testing is a framework for assessing the software testing process to improve it. It is based on the Capability Maturity Model(CMM). It was first produced by the Illinois Institute of Technology to assess the maturity of the test processes and to provide targ
    8 min read

    SDLC MODELS

    Waterfall Model - Software Engineering
    The Waterfall Model is a Traditional Software Development Methodology. It was first introduced by Winston W. Royce in 1970. It is a linear and sequential approach to software development that consists of several phases. This classical waterfall model is simple and idealistic. It is important because
    13 min read
    What is Spiral Model in Software Engineering?
    The Spiral Model is one of the most important SDLC model. The Spiral Model is a combination of the waterfall model and the iterative model. It provides support for Risk Handling. The Spiral Model was first proposed by Barry Boehm. This article focuses on discussing the Spiral Model in detail.Table o
    9 min read
    What is a Hybrid Work Model?
    Hybrid means a thing made by a combination of two different elements and the resulting hybrid element acquires characteristics of both underline elements. The following topics of the hybrid model will be discussed here:What is the Hybrid Model?Why the Hybrid Model?When To Use a Hybrid ModelProcess o
    13 min read
    Prototyping Model - Software Engineering
    Prototyping Model is a way of developing software where an early version, or prototype, of the product is created and shared with users for feedback. The Prototyping Model concept is described below: Table of ContentWhat is Prototyping Model?Phases of Prototyping ModelTypes of Prototyping ModelsAdva
    7 min read
    SDLC V-Model - Software Engineering
    The SDLC V-Model is a Types of Software Development Life Cycle (SDLC), which is used in Software Development process. In V-Model is the extension of the Traditional Software Development Model.It is creating a Structure like the "V" which includes the different phases which we are discussing here in
    10 min read

    TYPES OF TESTING

    Manual Testing - Software Testing
    Manual testing is an important part of software development. Unlike automated testing, it involves a person actively using the software to find bugs and issues. This hands-on approach helps ensure the software works as intended and meets user needs. Table of ContentWhat is Manual Testing Types of Ma
    14 min read
    Automation Testing - Software Testing
    Automated Testing means using special software for tasks that people usually do when checking and testing a software product. Nowadays, many software projects use automation testing from start to end, especially in agile and DevOps methods. This means the engineering team runs tests automatically wi
    15+ min read
`; $(commentSectionTemplate).insertBefore(".article--recommended"); } loadComments(); }); }); function loadComments() { if ($("iframe[id*='discuss-iframe']").length top_of_element && top_of_screen articleRecommendedTop && top_of_screen articleRecommendedBottom)) { if (!isfollowingApiCall) { isfollowingApiCall = true; setTimeout(function(){ if (loginData && loginData.isLoggedIn) { if (loginData.userName !== $('#followAuthor').val()) { is_following(); } else { $('.profileCard-profile-picture').css('background-color', '#E7E7E7'); } } else { $('.follow-btn').removeClass('hideIt'); } }, 3000); } } }); } $(".accordion-header").click(function() { var arrowIcon = $(this).find('.bottom-arrow-icon'); arrowIcon.toggleClass('rotate180'); }); }); window.isReportArticle = false; function report_article(){ if (!loginData || !loginData.isLoggedIn) { const loginModalButton = $('.login-modal-btn') if (loginModalButton.length) { loginModalButton.click(); } return; } if(!window.isReportArticle){ //to add loader $('.report-loader').addClass('spinner'); jQuery('#report_modal_content').load(gfgSiteUrl+'wp-content/themes/iconic-one/report-modal.php', { PRACTICE_API_URL: practiceAPIURL, PRACTICE_URL:practiceURL },function(responseTxt, statusTxt, xhr){ if(statusTxt == "error"){ alert("Error: " + xhr.status + ": " + xhr.statusText); } }); }else{ window.scrollTo({ top: 0, behavior: 'smooth' }); $("#report_modal_content").show(); } } function closeShareModal() { const shareOption = document.querySelector('[data-gfg-action="share-article"]'); shareOption.classList.remove("hover_share_menu"); let shareModal = document.querySelector(".hover__share-modal-container"); shareModal && shareModal.remove(); } function openShareModal() { closeShareModal(); // Remove existing modal if any let shareModal = document.querySelector(".three_dot_dropdown_share"); shareModal.appendChild(Object.assign(document.createElement("div"), { className: "hover__share-modal-container" })); document.querySelector(".hover__share-modal-container").append( Object.assign(document.createElement('div'), { className: "share__modal" }), ); document.querySelector(".share__modal").append(Object.assign(document.createElement('h1'), { className: "share__modal-heading" }, { textContent: "Share to" })); const socialOptions = ["LinkedIn", "WhatsApp","Twitter", "Copy Link"]; socialOptions.forEach((socialOption) => { const socialContainer = Object.assign(document.createElement('div'), { className: "social__container" }); const icon = Object.assign(document.createElement("div"), { className: `share__icon share__${socialOption.split(" ").join("")}-icon` }); const socialText = Object.assign(document.createElement("span"), { className: "share__option-text" }, { textContent: `${socialOption}` }); const shareLink = (socialOption === "Copy Link") ? Object.assign(document.createElement('div'), { role: "button", className: "link-container CopyLink" }) : Object.assign(document.createElement('a'), { className: "link-container" }); if (socialOption === "LinkedIn") { shareLink.setAttribute('href', `https://www.linkedin.com/sharing/share-offsite/?url=${window.location.href}`); shareLink.setAttribute('target', '_blank'); } if (socialOption === "WhatsApp") { shareLink.setAttribute('href', `https://api.whatsapp.com/send?text=${window.location.href}`); shareLink.setAttribute('target', "_blank"); } if (socialOption === "Twitter") { shareLink.setAttribute('href', `https://twitter.com/intent/tweet?url=${window.location.href}`); shareLink.setAttribute('target', "_blank"); } shareLink.append(icon, socialText); socialContainer.append(shareLink); document.querySelector(".share__modal").appendChild(socialContainer); //adding copy url functionality if(socialOption === "Copy Link") { shareLink.addEventListener("click", function() { var tempInput = document.createElement("input"); tempInput.value = window.location.href; document.body.appendChild(tempInput); tempInput.select(); tempInput.setSelectionRange(0, 99999); // For mobile devices document.execCommand('copy'); document.body.removeChild(tempInput); this.querySelector(".share__option-text").textContent = "Copied" }) } }); // document.querySelector(".hover__share-modal-container").addEventListener("mouseover", () => document.querySelector('[data-gfg-action="share-article"]').classList.add("hover_share_menu")); } function toggleLikeElementVisibility(selector, show) { document.querySelector(`.${selector}`).style.display = show ? "block" : "none"; } function closeKebabMenu(){ document.getElementById("myDropdown").classList.toggle("show"); }
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • DSA Tutorial
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences