Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
docs: Add testing guidelines for contributors  
- Included structured approach based on Berard's methodology.  
- Detailed steps for writing test cases, including examples for:  
  - Purpose  
  - Specified states  
  - Messages/operations  
  - Exceptions  
  - External conditions  
  - Supplementary information  
- Ensured clarity and modularity for ease of understanding.
  • Loading branch information
Jamaludiin authored Jan 14, 2025
1 parent c55af44 commit 36f697d
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions libs/text-splitters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,59 @@ Patch version increases will occur for:
As an open-source project in a rapidly developing field, we are extremely open to contributions, whether it be in the form of a new feature, improved infrastructure, or better documentation.

For detailed information on how to contribute, see the [Contributing Guide](https://python.langchain.com/docs/contributing/).


## Writing Test Case Guidelines

To ensure high-quality and maintainable testing, we follow a structured approach. Below is a step-by-step guideline for writing test cases effectively:

---

### Example: `test_character_text_splitter_keep_separator_regex`

#### **1. Unique Identifier**
- Use a descriptive method name in `snake_case` format.
**Example:** `test_character_text_splitter_keep_separator_regex`.

#### **2. Purpose**
- Clearly state the functionality or edge case being tested. Include this as a docstring after the test method definition.
**Example:**
> *To test the behavior of `CharacterTextSplitter` when a separator is a regex special character and needs to be retained in the output chunks.*
#### **3. Testing Steps**
Each test should include the following details:

- **a. Specified States:**
Clearly define the inputs, initial configurations, and state of the system.
**Example:**
```plaintext
Initial text: "foo.bar.baz.123"
Separator: "." (escaped or plain based on `is_separator_regex`)
Chunk size: 1
Chunk overlap: 0
Keep separator: True
- **b. Messages/Operations:**
List the specific operations or methods invoked in the test.
**Example:**
1. Initialize `CharacterTextSplitter` with the given configurations.
2. Call `splitter.split_text(text)`.
- **c. Exceptions (Optional):**
Mention any expected exceptions, if applicable.
- **d. External Conditions (Optional):**
Specify any external dependencies or conditions needed for the test.
**Example:** Requires Python's `re` module for `regex-based splitting`.
- **e. Supplementary Information:**
State the **expected output** or any additional details to help understand the test.
**Example:**
Expected result: `["foo", ".bar", ".baz", ".123"]`
#### **4. Clarity and Modularity**
Each test case should focus on testing one specific behavior or edge case.
The test setup, operations, and assertions should be concise and easy to follow.

0 comments on commit 36f697d

Please sign in to comment.