diff --git a/src/css/custom.css b/src/css/custom.css index 02b1ed500..074c00172 100644 --- a/src/css/custom.css +++ b/src/css/custom.css @@ -6,7 +6,7 @@ /* Hotfix: Changed primary color to black to resolve conflict with Docusaurus' default primary orange after disabling Tailwind preflight CSS. Added font size and line height adjustments to compensate for the removal of Tailwind preflight. */ /* --ifm-color-primary-lighter: #ffb575; */ - font-size:18px; + font-size:14px; line-height: 1.6; --ifm-color-primary: #000; --ifm-color-primary-lighter: #FFF; diff --git a/versioned_docs/version-2.0.0/concepts/reference/glossary/behaviour-driven-development.md b/versioned_docs/version-2.0.0/concepts/reference/glossary/behaviour-driven-development.md index 8d50de2b4..4b6d57ab7 100644 --- a/versioned_docs/version-2.0.0/concepts/reference/glossary/behaviour-driven-development.md +++ b/versioned_docs/version-2.0.0/concepts/reference/glossary/behaviour-driven-development.md @@ -1,8 +1,10 @@ --- id: behaviour-driven-development -title: What is Behavior Driven Development (BDD)? +title: "Behavior Driven Development : Beginner's Guide to Collaboration" sidebar_label: Behaviour Driven Development -description: Collaborative approach aligning software development with business goals through clear, readable test scenarios. +description: Learn how BDD bridges the gap between developers, testers, and business stakeholders with practical examples, tools, and techniques. +seoTitle: "Behavior Driven Development : Beginner's Guide to Collaboration" +seoDescription: Learn how BDD bridges the gap between developers, testers, and business stakeholders with practical examples, tools, and techniques. tags: - explanation - Glossary @@ -10,6 +12,13 @@ keywords: - API - BDD - Behavior Driven Development + - Behavior Driven Development Tools + - BDD Testing Tools + - Behavior Driven Testing + - Test Automation + - Software Testing + - Software Testing Best Practices + - Test Automation --- Behavior-driven development (BDD) is an Agile software development methodology that encourages collaboration between developers, testers, and business stakeholders. BDD is based on the idea that the best way to ensure that software meets the needs of its users is to write tests that describe the desired behavior of the software in plain language. @@ -136,17 +145,17 @@ One of the core practices in BDD is the creation of automated tests based on the Here are some of the popular BDD automation tools: -1. **Cucumber:** [Cucumber](https://github.com/cucumber/cucumber-js) is a free and open-source BDD tool that uses the Gherkin syntax for writing test cases in plain English. It can be programmed in several languages, including Java, Ruby, and JavaScript. +1. **Cucumber:** Cucumber is a free and open-source BDD tool that uses the Gherkin syntax for writing test cases in plain English. It can be programmed in several languages, including Java, Ruby, and JavaScript. Learn how to implement BDD with tools like Cucumber - [read now](https://keploy.io/blog/community/bdd-testing-with-cucumber)! 2. **Behave:** Behave is a behavior-driven testing tool written in Python that supports the Gherkin syntax and can be used in tandem with other testing frameworks like Pytest and Unittest. 3. **JBehave:** JBehave is a Gherkin-based, Java-based BDD tool that supports many testing frameworks, including JUnit and TestNG. -4. **SpecFlow:** [SpecFlow](https://github.com/SpecFlowOSS/SpecFlow) is a BDD tool that interfaces with Microsoft Studio and other .NET tools and employs the Gherkin syntax for writing specifications. It can be programmed in C# and Visual Basic, among other languages. +4. **SpecFlow:** SpecFlowis a BDD tool that interfaces with Microsoft Studio and other .NET tools and employs the Gherkin syntax for writing specifications. It can be programmed in C# and Visual Basic, among other languages. 5. **Gauge:** Gauge is an open-source BDD tool that employs a markdown-based syntax to describe tests. It can be programmed in Java, Ruby, and Python, among others. -6. **Reqnroll:** [Reqnroll](https://github.com/reqnroll/Reqnroll) is an open-source Cucumber-style BDD test automation framework for .NET. +6. **Reqnroll:** Reqnroll is an open-source Cucumber-style BDD test automation framework for .NET. These tools can help to streamline the testing process and improve communication between developers, testers, and stakeholders. This can help to ensure that the software meets the needs of the business and is of high quality. diff --git a/versioned_docs/version-2.0.0/concepts/reference/glossary/idempotency.md b/versioned_docs/version-2.0.0/concepts/reference/glossary/idempotency.md index c75f8be45..a2ad1a4ea 100644 --- a/versioned_docs/version-2.0.0/concepts/reference/glossary/idempotency.md +++ b/versioned_docs/version-2.0.0/concepts/reference/glossary/idempotency.md @@ -2,7 +2,7 @@ id: idempotency title: How Idempotent REST APIs Boost Reliability and Error Handling sidebar_label: Idempotency -description: Discover how idempotent APIs enhance user experience, reliability, and error handling. Learn best practices for implementing and testing idempotent methods. +description: Learn how idempotent REST APIs ensure reliability, error recovery, and fault tolerance in distributed systems. Discover best practices and testing strategies for idempotent methods tags: - explanation - glossary @@ -30,9 +30,9 @@ Idempotency is often associated with specific HTTP methods in RESTful APIs: ![Methods](https://www.hubspot.com/hs-fs/hubfs/Google%20Drive%20Integration/Idempotent%20Api%20Draft-1.png?width=650&name=Idempotent%20Api%20Draft-1.png) -## How Idempotency Ensures Reliability ? +## Key Benefits of Idempotent APIs -In distributed systems, where network failures and message duplication can occur, idempotent operations ensure reliability by: +In distributed systems, where multiple components often interact asynchronously, achieving consistency can be challenging. Network failures, latency, and message duplication can lead to unintended consequences if not handled carefully. This is where idempotency plays a pivotal role. Idempotent operations ensure reliability by: - **Preventing Duplicate Effects:** Even if a request is duplicated due to network issues or client retries, idempotent operations ensure that the system's state remains unchanged after the initial request. - **Simplifying Error Recovery:** Idempotent APIs simplify error recovery mechanisms by allowing clients to retry requests without causing additional modifications or inconsistencies in the system. @@ -46,9 +46,9 @@ Implementing idempotent APIs involves adopting best practices such as: - **Request Idempotency Tokens:** Use request headers or tokens (e.g., UUIDs) to uniquely identify and handle idempotent requests to prevent duplication or unintended re-execution. - **Idempotent Database Operations:** Implement database transactions and queries in a way that ensures data modifications are idempotent, even under concurrent or distributed execution scenarios. -### Challenges in Idempotent API Implementation +## Common Challenges in Implementing Idempotent APIs -Implementing and testing idempotent APIs can pose challenges such as: +Although idempotency is a desirable property in many RESTful APIs, implementing it in real-world systems can be challenging like : - **Ensuring Correctness Across Systems:** Guaranteeing idempotency in distributed systems with multiple interacting components requires careful design and coordination. - **Handling Edge Cases:** Identifying and addressing edge cases where idempotency might be violated due to specific system behaviors or failure scenarios. @@ -58,7 +58,7 @@ Implementing and testing idempotent APIs can pose challenges such as: Idempotency becomes particularly critical in distributed systems where network failures, message duplication, and out-of-order message delivery can occur. In such environments, ensuring that operations are idempotent helps prevent unintended side effects and ensures that the system can recover gracefully from failures without compromising data integrity. -### Idempotency important in RESTful APIs +### What is Idempotency in REST APIs? Idempotent APIs offer several benefits that contribute to the reliability, scalability, and consistency of systems. Here are some key advantages: @@ -95,13 +95,39 @@ Idempotent operations yield the same result regardless of repetitions. Safe meth ![Idempotent vs Safe](https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSNpJRr8DjkwYCknq1yp0PNVbGQ9Gy0rcBwtg&s) +## Leveraging Keploy for Idempotency in API Testing + +[Keploy](https://keploy.io), a powerful testing tool, plays a crucial role in handling **idempotency** during the development and testing phases of API design. By offering an **automated testing framework** that can simulate various API scenarios, including retries and error recovery, Keploy ensures that your idempotent APIs are functioning as expected across all edge cases. + +### How Keploy Helps Ensure Idempotency? + +- **Automated Test Cases for Idempotent Operations:** + Keploy enables developers to create automated test cases that simulate repeated API requests under various conditions, such as network failures, timeouts, or duplicate submissions. This ensures that idempotent operations like **PUT**, **DELETE**, and **GET** methods behave correctly, even when called multiple times. Keploy’s test cases can automatically validate that these methods do not introduce unexpected side effects or inconsistencies, regardless of how many times the request is repeated. + +- **Simulating Failures and Retrying Requests:** + With Keploy’s capabilities, teams can simulate failure scenarios, including transient network issues or service unavailability, to ensure that retry logic in idempotent APIs works as intended. This is especially important in distributed systems where failure recovery is crucial. Keploy verifies that retries do not modify the system’s state and that the response to a repeated request is consistent with the first execution, maintaining data integrity. + +- **Request and Response Pairing:** + Keploy also tracks requests and their corresponding responses, allowing you to easily identify whether repeated requests with the same data produce identical results. This pairing feature helps test whether the API is handling **idempotent tokens** (e.g., UUIDs) correctly and consistently across different test runs, ensuring that requests are not duplicated or re-executed unnecessarily. + +- **Advanced Mocking and Stubbing:** + In scenarios where you need to test idempotent behaviors in isolation or in specific conditions, Keploy allows you to mock external services and interactions. By simulating service responses, you can ensure that your idempotent APIs are handling edge cases effectively and returning the same results even in the event of temporary failures or delays. + +### Example Use Case + +Let’s say you are building an API that allows users to update their profile information using the **PUT** method. To ensure the operation is idempotent, you would create automated tests with Keploy to verify that: + +1. **Multiple PUT requests with identical data** will result in the same updated resource without introducing new records or changes. +2. **Simulated network failures** will not lead to multiple updates or changes to the user’s profile when the request is retried. +3. **Caching behaviors** are respected, ensuring that multiple requests for the same resource return the same data without additional overhead. + ## Conclusion Idempotency is a fundamental principle in designing reliable and scalable RESTful APIs. By ensuring that operations can be safely retried without adverse effects, idempotent APIs contribute to system reliability, consistency, and performance. Implementing idempotent APIs involves careful consideration of HTTP methods, data handling, and error recovery mechanisms to maintain data integrity and simplify client interactions. -Certainly! Here are 6 FAQs about idempotent REST APIs: +Tools such as Keploy simplifies handling of idempotency during testing by providing a robust platform to simulate real-world API usage and edge cases, ensuring your APIs maintain their idempotency even under adverse conditions. -## Frequently Asked Questions +## FAQ ### What does it mean for an HTTP method to be idempotent? @@ -119,7 +145,7 @@ Examples of idempotent HTTP methods include: - **PUT:** Updating a resource with PUT results in the same state regardless of how many times it's applied. - **DELETE:** Deleting a resource using DELETE remains unchanged if the resource is already deleted or does not exist. -### How does idempotency contribute to error handling and fault tolerance? +### How does idempotency improve error handling in distributed systems? Idempotent APIs simplify error handling and fault tolerance by allowing clients to retry requests safely. If a request fails due to network issues or timeouts, clients can resend the request without worrying about introducing inconsistencies or unintended modifications in the server's state. @@ -131,6 +157,6 @@ To ensure idempotency in API implementations, developers should: - Implement operations in a way that does not change the server's state if the request is repeated. - Use request headers or tokens to uniquely identify and handle idempotent requests to prevent duplicate execution. -### How can developers test for idempotency in REST APIs? +### How to test idempotent APIs? Testing for idempotency involves creating test cases that simulate scenarios where requests may be duplicated or retried due to network failures or client retries. Developers should verify that repeating the same request does not result in different outcomes or unintended side effects in the system's state. diff --git a/versioned_docs/version-2.0.0/concepts/reference/glossary/test-driven-development.md b/versioned_docs/version-2.0.0/concepts/reference/glossary/test-driven-development.md index 43e3f05af..313b93ae5 100644 --- a/versioned_docs/version-2.0.0/concepts/reference/glossary/test-driven-development.md +++ b/versioned_docs/version-2.0.0/concepts/reference/glossary/test-driven-development.md @@ -1,18 +1,28 @@ --- id: test-driven-development -title: What is Test Driven Development (TDD)? +title: What is Test Driven Development (TDD)? Benefits, Process, and Tools sidebar_label: Test Driven Development -description: Collaborative approach aligning software development with business goals through clear, readable test scenarios. +description: Learn about Test Driven Development (TDD), its benefits, best practices, and how it ensures high-quality code through structured testing before implementation. Explore the TDD workflow and integration with tools like Keploy. tags: - explanation - Glossary keywords: - API + - test Driven Development (TDD) + - TDD Best Practices + - TDD Workflow + - Keploy and Test Driven Development + - Continuous Integration with TDD + - How to Implement TDD + - TDD Testing Tools + - Challenges of Test Driven Development --- -Test Driven Development (TDD) is a software development approach that aligns software development with business goals through clear, readable test scenarios. Test Driven Development is a collaborative approach that involves developers, testers, and business analysts working together to define the requirements and test scenarios before writing the code. +Test Driven Development (TDD) is a dynamic and collaborative approach to software development that brings together developers, testers, and business analysts to ensure code aligns perfectly with business objectives. Instead of diving straight into writing code, TDD starts with a clear plan — in the form of well-defined, readable test scenarios. These tests act as a blueprint, guiding the development process and ensuring that the code will meet the desired requirements right from the start. -## When to work with TDD ? +The best part? By writing tests before code, TDD helps catch issues early, fosters cleaner and more modular code, and ensures that each feature is thoroughly tested as it’s built. This not only leads to higher-quality software but also keeps the development process aligned with business goals, making it a win-win for everyone involved. + +## How TDD Works ? Test Driven Development or TDD is particularly useful in the following scenarios: @@ -29,9 +39,13 @@ Test Driven Development or TDD is particularly useful in the following scenarios ### Fundamentals of TDD 1. **Write a Failing Test**: + - Start by writing a test that defines a new function or improvement. This test should fail initially as the feature is not yet implemented. + 2. **Implement the Minimum Code**: + - Write the minimum amount of code required to make the test pass. Focus on functionality rather than optimization. + 3. **Refactor the Code**: - Once the test passes, refactor the code to improve its structure and maintainability. Ensure the test still passes after refactoring. @@ -56,11 +70,60 @@ Test Driven Development or TDD is particularly useful in the following scenarios 6. **Behavioral Testing**: - Although primarily focused on unit testing, incorporate behavioral tests to ensure that the system behaves as expected from the user's perspective. Use tools like JUnit for Java or pytest for Python. -## How Keploy works with Test Driven Development ? +## **Why TDD is Important?** + +Test Driven Development (TDD) is important because it lays a solid foundation for reliable, maintainable, and bug-free software. By writing tests before writing the code, TDD helps ensure that each piece of functionality is clearly defined, easy to validate, and meets the specified requirements. Here are a few reasons why TDD is crucial: + +- **Early Detection of Bugs**: Writing tests before implementing the code means that any errors or issues in the logic are caught right at the beginning of the development process, reducing the chances of defects slipping through unnoticed. +- **Improved Code Quality**: TDD encourages developers to write modular and testable code. As tests are written first, developers are more likely to design smaller, more focused code units, making the software more maintainable in the long term. + +- **Clearer Requirements**: Writing tests based on business requirements ensures that the software will meet expectations. TDD pushes teams to think about the functionality and edge cases up front, promoting clearer and better communication among developers, testers, and business stakeholders. + +- **Refactoring Safety**: One of the key benefits of TDD is that it provides a safety net for refactoring. When you have tests in place, you can confidently make changes to the codebase knowing that the tests will verify whether your changes break any functionality. + +- **Faster Debugging**: Since tests are written incrementally, you can easily pinpoint the origin of a bug by identifying which test failed. This allows you to debug the application more efficiently. + +- **Continuous Feedback**: By running tests continuously throughout the development process, developers get rapid feedback on the quality and correctness of their code, allowing for quick adjustments when necessary. + +## **Why Choose TDD over BDD?** + +Test Driven Development offers a systematic approach that benefits both developers and the larger development process. Here’s why you should choose TDD: + +- **Reduces Debugging Time**: By catching issues early in the development process through unit tests, developers spend less time debugging in the later stages. The continuous feedback loop from TDD helps catch defects before they propagate and complicate the development process. + +- **Promotes Better Design**: TDD encourages developers to write clean, modular, and decoupled code. The need to write tests first forces developers to think about the code structure and design, which leads to a more maintainable and scalable architecture. -Keploy can be integrated into your Test Driven Development workflow to automate testing processes and streamline development. +- **Supports Continuous Integration**: TDD naturally fits into continuous integration (CI) workflows. Since tests are written upfront, they can be easily integrated into a CI/CD pipeline, ensuring that the code is continuously validated as new changes are made. + +- **Increased Confidence in Code**: With TDD, you’re constantly testing the code as you write it, which gives you confidence in the functionality and quality of your work. You also get the reassurance that your code behaves as expected, which is especially important in high-stakes environments like production. + +- **Facilitates Collaboration**: TDD bridges the gap between developers and testers, as everyone works off the same set of predefined tests. It also involves business analysts or product owners in the test design process, ensuring that the code delivered is aligned with business objectives. + +- **Helps with Legacy Code**: When dealing with legacy systems or refactoring old code, TDD can help ensure that existing functionality is not broken. The tests act as a safeguard, providing assurance that your changes do not inadvertently introduce bugs into existing features. + +- **Focus on What to Build, Not How**: By focusing on the behavior of the system through tests, TDD helps clarify the user story or requirement before developers begin writing code. This clarity leads to more focused and purpose-driven development. + +## **Common Challenges with TDD** + +While Test Driven Development offers many advantages, it does come with its own set of challenges. Here are some common hurdles teams face when implementing TDD and how to overcome them: + +- **Initial Learning Curve**: Adopting TDD can be challenging for developers who are not familiar with the approach. It requires a shift in mindset, where writing tests before writing code becomes the norm. To overcome this, teams can start with smaller, simpler projects and gradually increase their adoption of TDD practices over time. Pair programming is also a useful way to mentor developers through the process. + +- **Time-Consuming Initially**: TDD requires writing tests before coding, which might seem like it slows down development at first. However, in the long run, the reduced need for debugging and the prevention of defects often leads to faster development. To mitigate this challenge, ensure that the team understands the long-term benefits of TDD and integrates it gradually into their workflow. + +- **Difficulty Writing Tests for Complex Logic**: For systems with highly complex logic or deep dependencies, writing meaningful unit tests can be a challenge. It may be difficult to determine how to isolate certain pieces of functionality for testing. Using **mocking** and **stubbing** techniques can help simulate external dependencies and make testing easier. + +- **Test Maintenance Overhead**: As the codebase evolves, tests may require updates to accommodate changes in the code. If not maintained carefully, tests can become stale and difficult to manage. To counter this, focus on writing clean, simple tests that are easy to update as the code changes. Automated refactoring tools and regular code reviews can help manage this challenge. + +- **Not Suitable for All Types of Testing**: TDD is highly effective for unit tests but may not always be the best approach for more complex system tests or UI-level testing. Some projects, such as those with rapidly changing UIs or where the external system dependencies are difficult to mock, may benefit from a more flexible testing strategy, such as [**Behavior Driven Development (BDD)**](https://keploy.io/docs/concepts/reference/glossary/behaviour-driven-development/) or [**Exploratory Testing**](https://keploy.io/blog/community/how-exploratory-testing-can-improve-software-quality). + +- **Overemphasis on Test Coverage**: While TDD encourages writing tests, it’s important not to focus solely on achieving 100% test coverage. Sometimes, writing tests for trivial code or edge cases that aren’t critical to the application can introduce unnecessary complexity. It's better to prioritize writing meaningful, high-quality tests that ensure the most critical functionality works as expected. + +- **Pressure to Stick to Small Increments**: TDD encourages writing small, incremental code changes, but this can sometimes feel slow, especially for developers used to working in larger chunks. It's important to strike a balance between small iterations and the need to implement features in a reasonable timeframe. Communication with stakeholders about the benefits of TDD and its impact on overall software quality can help set realistic expectations. + +## How Keploy works with Test Driven Development ? -Here's how you can perform TDD with Keploy: +[Keploy](https://keploy.io) can be integrated into your Test Driven Development workflow to automate testing processes and streamline development.Here's how you can perform TDD with Keploy: - **Write a Failing Test**: Begin by writing a test case for a specific functionality or requirement of your application. The test should fail initially since the corresponding functionality has not been implemented yet. @@ -79,18 +142,18 @@ Here's how you can perform TDD with Keploy: ## Comparison Table: TDD vs. BDD vs. Traffic Driven Testing -| Aspect | Test Driven Development (TDD) | Behavior Driven Development (BDD) | Traffic Driven Testing (Traffic) | -| ---------------------- | ---------------------------------------------- | -------------------------------------------------------------------- | ---------------------------------------------------------------- | -| **Primary Focus** | Unit testing and code design | Collaboration and end-user behavior | Real-world traffic simulation and testing | -| **Tests Written By** | Developers | Collaboration between developers, testers, and business stakeholders | Developers and testers using real traffic data | -| **Language for Tests** | Programming language of the application | Natural language (Gherkin syntax) | Real traffic data captured from production | -| **Testing Levels** | Primarily unit testing | Acceptance, integration, and system testing | End-to-end, performance, and load testing | -| **Tools** | JUnit, pytest, NUnit | Cucumber, SpecFlow, Behave | Traffic simulators, load testing tools, Keploy | -| **Documentation** | Code-focused tests that serve as documentation | Plain language scenarios accessible to non-technical stakeholders | Traffic patterns and logs | -| **Target Audience** | Primarily developers | Both technical and non-technical team members | Developers, testers, and operations teams | -| **Cycle** | Write tests, implement code, refactor | Define behavior, write scenarios, automate tests, validate behavior | Capture traffic, simulate/test traffic, analyze results | -| **Emphasis** | Code correctness | Meeting user expectations and business goals | Real-world user behavior and system performance | -| **Collaboration** | Primarily within development team | High collaboration across all stakeholders | Collaboration between development, testing, and operations teams | +| Aspect | Test Driven Development (TDD) | Behavior Driven Development (BDD) | Traffic Driven Testing (Traffic) | +| ---------------------- | --------------------------------------------------------------- | -------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | +| **Primary Focus** | Unit testing and code design | Collaboration and end-user behavior | Real-world traffic simulation and testing | +| **Tests Written By** | Developers | Collaboration between developers, testers, and business stakeholders | Developers and testers using real traffic data | +| **Language for Tests** | Programming language of the application | Natural language (Gherkin syntax) | Real traffic data captured from production | +| **Testing Levels** | Primarily [unit testing](https://keploy.io/unit-test-generator) | Acceptance, integration, and system testing | End-to-end, performance, and [load testing](https://keploy.io/blog/community/all-about-load-testing-a-detailed-guide) | +| **Tools** | JUnit, pytest, NUnit | Cucumber, SpecFlow, Behave | Traffic simulators, load testing tools, Keploy | +| **Documentation** | Code-focused tests that serve as documentation | Plain language scenarios accessible to non-technical stakeholders | Traffic patterns and logs | +| **Target Audience** | Primarily developers | Both technical and non-technical team members | Developers, testers, and operations teams | +| **Cycle** | Write tests, implement code, refactor | Define behavior, write scenarios, automate tests, validate behavior | Capture traffic, simulate/test traffic, analyze results | +| **Emphasis** | Code correctness | Meeting user expectations and business goals | Real-world user behavior and system performance | +| **Collaboration** | Primarily within development team | High collaboration across all stakeholders | Collaboration between development, testing, and operations teams | ![TDD vs. BDD vs. Traffic Driven Testing](https://images.ctfassets.net/vrc8wif0t20g/6YGzPeOoQlewSQ07sX7a9P/6815d8dffd1523e43040b17e78a39f73/BDD_vs._TDD__Differences_Explained.png) @@ -98,28 +161,28 @@ Here's how you can perform TDD with Keploy: In conclusion, Test Driven Development (TDD) is a valuable approach for software development. It provides numerous benefits such as ensuring code quality, facilitating bug fixing and troubleshooting, and encouraging modular and maintainable code. By writing tests first, developers can define the expected behavior of their code and verify that it meets the specified requirements. TDD can be integrated into the development workflow with tools like Keploy, automating testing processes and streamlining development. While TDD may not be suitable for all projects, it is a powerful technique that can greatly enhance the quality and reliability of software. -## FAQs about Test Driven Development (TDD) +## FAQ -### 1. **What is Test Driven Development (TDD)?** +### **What is Test Driven Development (TDD)?** Test Driven Development (TDD) is a software development approach where tests are written before the actual code. It focuses on defining the requirements and test scenarios upfront to ensure that the code meets the specified functionality. -### 2. **What are the main benefits of TDD?** +### **What are the main benefits of TDD?** TDD helps ensure code quality, encourages modular and maintainable code, facilitates bug fixing and troubleshooting, and provides a safety net for refactoring legacy code. -### 3. **How does TDD differ from BDD?** +### **How does TDD differ from BDD?** TDD focuses on writing unit tests before coding, emphasizing code correctness and design. BDD, on the other hand, focuses on collaboration and defining behavior from the user's perspective using natural language scenarios. -### 4. **Can TDD be used for all types of projects?** +### **Can TDD be used for all types of projects?** While TDD is highly effective for many types of projects, it may not be suitable for all. Projects with rapidly changing requirements or those that require extensive UI testing might benefit more from complementary approaches like BDD or Traffic Driven Testing. -### 5. **What are the challenges of implementing TDD?** +### **What are the challenges of implementing TDD?** Challenges include the initial learning curve, the need for disciplined test writing, potential increased development time upfront, and the difficulty of writing tests for complex or legacy codebases. -### 6. **How can TDD be integrated into a CI/CD pipeline?** +### **How can TDD be integrated into a CI/CD pipeline?** TDD can be integrated into a CI/CD pipeline by automating the execution of tests with each code commit, monitoring code coverage, and ensuring that tests are consistently run to maintain code quality throughout the development lifecycle. diff --git a/versioned_docs/version-2.0.0/concepts/reference/glossary/unit-test-automation.md b/versioned_docs/version-2.0.0/concepts/reference/glossary/unit-test-automation.md index e90cff4cf..92e35eae2 100644 --- a/versioned_docs/version-2.0.0/concepts/reference/glossary/unit-test-automation.md +++ b/versioned_docs/version-2.0.0/concepts/reference/glossary/unit-test-automation.md @@ -1,15 +1,38 @@ --- id: unit-test-automation -title: What is Unit Test Automation? -seoTitle: "Understanding Unit Test Automation: A Comprehensive Guide" -seoDescription: "Discover what unit test automation is, its benefits, best practices, and how it streamlines software development for better quality." +title: "Master Unit Test Automation: A Developer’s Essential Guide" +seoTitle: "Master Unit Test Automation: A Developer’s Essential Guide" +seoDescription: Discover how to simplify testing workflows with our expert guide to unit test automation. Tools, benefits, and best practices all in one place! sidebar_label: Unit Test Automation -description: Simplify Your Testing Workflow with Unit Test Automation. Streamline processes for efficient and effective software testing. +description: Discover how to simplify testing workflows with our expert guide to unit test automation. Tools, benefits, and best practices all in one place! tags: - explanation - Glossary keywords: - API + - Unit testing tools + - Test automation + - Automated testing frameworks + - Unit test best practices + - Continuous integration + - Test-driven development (TDD) + - Software testing + - Code quality assurance + - Automated testing benefits + - Unit testing examples + - Python unit tests + - Java unit testing + - Unit testing frameworks comparison + - Mock testing + - Code reliability + - CI/CD testing automation + - Unit test automation for developers + - Unit testing in software development + - Automated test scripts + - Bug detection through unit testing + - Software development testing tools + - ai testing agent + - opensource testing agent --- Automating Unit Test is the practice of using automated tools and scripts to execute a set of predefined tests on individual units of code. These tests verify that each unit functions as intended, isolating and validating specific functionalities in an automated and repeatable manner. @@ -94,11 +117,11 @@ Integrate your unit tests into your CI/CD pipeline to ensure they run automatica - **Ignoring Test Failures**: Treat failing tests as a critical issue rather than a minor inconvenience. Investigate and fix them promptly to maintain the integrity of your code. -## What are some unit test automation tools? +## Best Tools for Automated Unit Testing There are many unit testing tools available for a wide range of languages and environments. Some popular tools include: -### Keploy +### How to Use Keploy for Unit Testing Keploy offers a one-click unit test generation tool that streamlines the testing process for developers. Instead of spending time writing test cases from scratch, you can generate them instantly, allowing you to focus on coding and delivering new features. @@ -109,7 +132,7 @@ Keploy offers a one-click unit test generation tool that streamlines the testing - **Focus on Quality**: Spend more time writing high-quality code while ensuring thorough validation. ![Keploy](../../../../../static/img/glossary/keploy_VS.png) -Get started by downloading the tool from the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=Keploy.keployio) and boost your development workflow today! +Learn how to automate unit tests with these tools - [click to explore](https://keploy.io/blog/community/boost-unit-test-efficiency-using-ai-powered-extensions-for-vs-code)! ### pytest (Python) diff --git a/versioned_docs/version-2.0.0/concepts/reference/glossary/unit-testing.md b/versioned_docs/version-2.0.0/concepts/reference/glossary/unit-testing.md index 2bc42c959..a31c6b9a5 100644 --- a/versioned_docs/version-2.0.0/concepts/reference/glossary/unit-testing.md +++ b/versioned_docs/version-2.0.0/concepts/reference/glossary/unit-testing.md @@ -13,6 +13,30 @@ keywords: - software testing - e2e testing - integration testing + - automated unit testing + - unit test automation tools + - test case generation + - test-driven development + - debugging tools for testing + - JUnit integration + - PHPUnit testing + - PyTest unit tests + - Selenium testing + - test case validation + - dynamic test cases + - unit testing frameworks + - Keploy test automation + - continuous integration testing + - automated testing for developers + - bug detection in unit tests + - test automation best practices + - software quality assurance + - automated test debugging + - unit testing benefits + - test coverage tools + - CI/CD and testing + - ai testing agent + - opensource testing agent --- ## What is Unit Testing? diff --git a/versioned_docs/version-2.0.0/keploy-explained/common-errors.md b/versioned_docs/version-2.0.0/keploy-explained/common-errors.md new file mode 100644 index 000000000..db15e9afe --- /dev/null +++ b/versioned_docs/version-2.0.0/keploy-explained/common-errors.md @@ -0,0 +1,202 @@ +--- +id: errors +title: Common Errors in Keploy +sidebar_label: Common Errors +tags: + - explanation + - faq +--- + +Let's check some of the common errors that you might encounter while working with Keploy! + +[](https://camo.githubusercontent.com/74cbc79070c04e7077cfd86981c110678fe434e9269ea8f52eafb37b781cfb4a/68747470733a2f2f646f63732e6b65706c6f792e696f2f696d672f6b65706c6f792d6c6f676f2d6461726b2e7376673f733d32303026763d34) + +### 1. Dependency Not Found Error + +#### Description: + +This error occurs when Keploy cannot locate or access a required dependency, such as a database or external service. + +#### Possible Cause: + +- The dependency may not be running or is incorrectly configured. +- Networking issues may be preventing Keploy from connecting to external dependencies. + +#### Solution: + +- Verify that all required services (e.g., databases, third-party APIs) are active and accessible. +- Check the environment variables or configuration files to confirm the correct host and port details. +- Use network diagnostic tools (e.g., ping, traceroute) to identify connectivity issues. + +### 2. Unable to Record API Calls + +#### Description: + +Keploy fails to record incoming API traffic, meaning no tests are generated. + +#### Possible Cause: + +- Incorrect integration with the application. +- Keploy may not be correctly started with the application, or the SDK is not configured properly. +- The application may not be making API calls that are recognizable by Keploy. + +#### Solution: + +- Double-check the integration guide for the programming language you’re using. +- Ensure that Keploy is properly hooked into the API layer. +- Check Keploy logs for any missed or skipped requests. + +### 3. Test Replay Failure + +#### Description: + +Keploy is unable to replay recorded API requests. + +#### Possible Cause: + +- External services or databases may be in a different state than they were during recording. +- Non-deterministic values like timestamps, UUIDs, or random values are causing failures. + +#### Solution: + +- Leverage Keploy’s mocking capabilities to simulate external services and databases. +- Use configurations to handle or exclude non-deterministic values for consistent comparisons. +- Regularly reset the database state to match the conditions during recording. + +### 4. Response Mismatch Error + +#### Description: + +When Keploy replays API calls, it detects a mismatch between the recorded response and the current response. + +#### Possible Cause: + +- The application’s behavior has changed, leading to different responses. +- Changes in the response format, status codes, or headers that weren’t present during recording. + +#### Solution: + +- Review the application changes and determine if the mismatch is expected (e.g., new features). +- If the change is acceptable, update the test baseline to reflect the new behavior. +- Use Keploy’s flexible comparison options to ignore certain fields or values (like timestamps or version numbers). + +### 5. Incorrect Test Generation + +#### Description: + +Keploy generates tests that don’t properly reflect the API interactions. + +#### Possible Cause: + +- The API interaction may be too complex or involve custom logic that Keploy cannot automatically handle. +- API parameters may be missing or misinterpreted during recording. + +#### Solution: + +- Review the recorded test cases for correctness. +- Manually adjust the generated tests to include missing or misinterpreted parameters. +- Make use of Keploy’s API to refine the recording process if necessary. + +### 6. Database Connection Error during Test Replay + +#### Description: + +Keploy cannot connect to the database or other external systems during the replay of tests. + +#### Possible Cause: + +- The test environment may not have access to the same database as the original recording. +- Database credentials or host information could be incorrect or missing in the test environment. + +#### Solution: + +- Mirror the test environment configuration with the recording setup. +- Use database mocks or stubs for isolated testing. +- Double-check connection strings, credentials, and database availability. + +### 7. Missing or Invalid Configuration Error + +#### Description: + +Keploy cannot find a valid configuration file or encounters errors in the configuration. + +#### Possible Cause: + +- The Keploy configuration file (keploy.yaml or similar) is missing or contains invalid values. +- Environment variables required by Keploy may not be set. + +#### Solution: + +- Ensure the configuration file exists and follows the correct format. +- Populate all required fields with valid values. +- Check that environment variables are properly set. + +### 8. Timeout Errors + +#### Description: + +Keploy times out while recording or replaying API calls. + +#### Possible Cause: + +- Long-running API requests or slow external dependencies can cause timeout issues. +- Keploy may have low timeout settings for API calls. + +#### Solution: + +- Increase timeout settings in the Keploy configuration. +- Identify and optimize slow-performing APIs or dependencies. +- Use monitoring tools to analyze API performance. + +### 9. Insufficient Permissions + +#### Description: + +Keploy fails due to insufficient permissions when accessing files, networks, or other resources. + +#### Possible Cause: + +The user or service running Keploy may not have sufficient permissions to access resources like databases, APIs, or file systems. + +#### Solution: + +- Ensure that the user or service running Keploy has the necessary permissions. +- Review system permissions and provide the required access rights for Keploy to function properly. + +### 10. Version Compatibility Issues + +#### Description: + +Errors occur because of version mismatches between Keploy, its dependencies, or the application it’s testing. + +#### Possible Cause: + +- Using incompatible versions of Keploy or related SDKs with your application. +- Dependencies of Keploy (e.g., for mocking or replaying) may have updated and broken compatibility. + +#### Solution: + +- Verify version compatibility for Keploy and its SDKs. +- Consult Keploy documentation or release notes for known issues. +- Use version pinning to maintain a stable environment. + +### 11. Unsupported Protocol or API + +#### Description: + +Keploy does not support the protocol or API structure you are using (e.g., gRPC, SOAP, etc.). + +#### Possible Cause: + +- The application might use an API or protocol that Keploy doesn’t yet support (e.g., WebSocket, gRPC). + +#### Solution: + +- Confirm the supported protocols (currently HTTP/REST and GraphQL). +- Consider alternative tools or frameworks for unsupported protocols. + +If you’re still encountering issues after trying these solutions, feel free to reach out to the Keploy team or consult the community forums for additional support. Happy testing! + +import GetSupport from '../concepts/support.md' + + diff --git a/versioned_docs/version-2.0.0/keploy-explained/mac-linux.md b/versioned_docs/version-2.0.0/keploy-explained/mac-linux.md index b83429b36..eecf4f1b0 100644 --- a/versioned_docs/version-2.0.0/keploy-explained/mac-linux.md +++ b/versioned_docs/version-2.0.0/keploy-explained/mac-linux.md @@ -1,7 +1,7 @@ --- id: mac-linux title: "Running Keploy Natively on MacOS by setting up a linux env" -sidebar_label: Keploy on MacOS native +sidebar_label: MacOS Native --- # Running Keploy Natively on MacOS by setting up a linux env diff --git a/versioned_sidebars/version-2.0.0-sidebars.json b/versioned_sidebars/version-2.0.0-sidebars.json index a65023772..71daa0687 100644 --- a/versioned_sidebars/version-2.0.0-sidebars.json +++ b/versioned_sidebars/version-2.0.0-sidebars.json @@ -45,7 +45,7 @@ "type": "category", "label": "Quickstart Guide", "collapsible": true, - "collapsed": true, + "collapsed": false, "items": [ { "type": "category", @@ -163,7 +163,8 @@ "collapsible": true, "collapsed": true, "items": [ - "keploy-explained/faq" + "keploy-explained/faq", + "keploy-explained/errors" ] } ],