Git Product home page Git Product logo

debuggers-cli's Introduction

Automatic Test Code Generation CLI

This CLI tool is designed to assist in generating test scenarios and test codes for a React application. It uses OpenAI's language model to generate test-related content based on provided inputs and the repository's source code.

Prerequisites

Before using this tool, make sure you have the following:

  • A public GitHub repository containing the React application.
  • An OpenAI API key.
  • Python 3.6 or above installed.

Setup

  1. Clone this repository to your local machine.

  2. Install the required Python packages by running the following command in the project directory:

    pip install -r requirements.txt
    
  3. Rename the .env.example file to .env and update the following values:

    OPENAI_API_KEY=[YOUR OPENAI API KEY]
    GIT_REPOSITORY=[GIT REPOSITORY URL]
    TEST_SCENARIO_COUNT=[NUMBER OF TEST SCENARIOS TO GENERATE]
    

    Replace the placeholders with your OpenAI API key, the URL of the GitHub repository, and the desired number of test scenarios to generate.

Usage

The CLI tool provides the following commands:

1. Generate File Summary YAML

This command generates YAML files that summarize and explain each file in the React application.

Command:

python yaml_gen.py -m summary-gen

This command analyzes the source code files in the specified GitHub repository and generates a YAML file for each file. The YAML file contains important information about the file.

Note: Make sure to run this command before running the test-scenario-gen and test-gen commands.

2. Generate Test Scenarios

This command generates test scenarios based on the file summaries generated in the previous step.

Command:

python yaml_gen.py -m test-scenario-gen

This command generates 30 test scenarios based on the file summaries. It then selects a specified number of important test scenarios related to users from the Project Manager's perspective.

3. Generate Test Codes

This command generates test codes for the specified number of test scenarios.

Command:

python yaml_gen.py -m test-gen

This command uses the generated test scenarios and generates professional and detailed end-to-end (E2E) test codes in JavaScript using Node.js and Jest.

Example Repository

To test the CLI tool, you can use the following example repository:

Make sure to update the GIT_REPOSITORY value in the .env file with the desired repository URL.

Alternate Idea: HTML Summarizer

html_yaml.py is an alternate idea that we introduced in midterm, but we did not actually use, so it remains as an alternate idea. The way it works is by summarizing html page and collecting all the interative objects.

NOTE: It is made based on yaml_gen.py, and not part of the main implementation.

Usage

  1. Name the website and provide link
WEB_NAME = "python_tutorial"
WEB_LINK = "https://www.w3schools.com/python/python_file_write.asp"
  1. Create summary of html page
python html_yaml.py -m summary-gen
  1. Fetch all interactive elements.

By using the previous summary:

python html_yaml.py -m fetch-sect

Without using the previous summary:

python html_yaml.py -m fetch-elems
  1. Generate test scenario
python html_yaml.py -m test-scenario-gen
  1. Generate test cases
python html_yaml.py -m test-gen

Important Notes

  • Make sure to run the commands in the specified order (summary-gen -> test-scenario-gen -> test-gen).
  • The generated files will be stored in the generated directory within the project.
  • You can customize the behavior of the language model by modifying the code in the yaml_gen.py file.

Feel free to reach out if you have any questions or encounter any issues.

debuggers-cli's People

Contributors

adzaky15 avatar xmhw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.