Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aashutoshrathi/testcase-generator
⚡️ Handy script for HackerRank, HackerEarth and CodeChef TCs Generation.
https://github.com/aashutoshrathi/testcase-generator
cases hackerrank testing testing-tools
Last synced: 12 days ago
JSON representation
⚡️ Handy script for HackerRank, HackerEarth and CodeChef TCs Generation.
- Host: GitHub
- URL: https://github.com/aashutoshrathi/testcase-generator
- Owner: aashutoshrathi
- License: mit
- Created: 2017-09-30T14:30:25.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-01T08:43:42.000Z (about 1 month ago)
- Last Synced: 2024-10-11T09:15:39.012Z (27 days ago)
- Topics: cases, hackerrank, testing, testing-tools
- Language: Python
- Homepage: https://tcgen.aashutosh.dev/
- Size: 9.18 MB
- Stars: 104
- Watchers: 8
- Forks: 53
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Testcase Generator
[](#)
[![](https://img.shields.io/travis/aashutoshrathi/Testcase-Generator?style=for-the-badge)](https://travis-ci.org/aashutoshrathi/Testcase-Generator)
Handy script to generate Test Cases for [HackerRank](https://www.hackerrank.com), [HackerEarth](https://www.hackerearth.com) and [CodeChef](https://www.codechef.com) Problems
Are you a Problem Author?
The toughest part of creating a problem is creating tricky, correct and constrained Test Cases.
Well, here is a handy **Python** Script, for your respective logic (solution).# Table of Contents
- [Testcase Generator](#testcase-generator)
- [Table of Contents](#table-of-contents)
- [Mentions](#mentions)
- [Supported Languages](#supported-languages)
- [Install](#install)
- [How to Use ? 😃](#how-to-use--)
- [How it Works ? 🤔](#how-it-works--)
- [Setup using Docker 🐳](#setup-using-docker-)
- [Running Tests ✅](#running-tests-)
- [FAQ 📃](#faq-)
- [Contributors ✨](#contributors-)
- [Stargazers over time 📈](#stargazers-over-time-)# Mentions
- [Blog post](https://medium.com/@agarwalrounak/my-nwoc-njack-winter-of-code-2018-experience-badf30b9c02d) on experince in NWoC 2018 by Rounak Agarwal.
- Selected as project in [GSSoC 2019](https://www.gssoc.tech/projects.html)
- Selected as project in [NJACKWinterOfCode 2018](<[https://github.com/NJACKWinterOfCode/HackerRank-Test-Case-Generator](https://njackwinterofcode.github.io/)>)# Supported Languages
The following languages are supported for testcase generation:
- [C](/tc_generator/logic.c)
- [C++](/tc_generator/logic.cpp)
- [Java](/tc_generator/logic.java)
- [Python](/tc_generator/logic.py)
- [C#](/tc_generator/logic.cs)
- [Go](/tc_generator/logic.go)# Install
## How to Use ? 😃
- Clone the repository `$ git clone https://github.com/aashutoshrathi/Testcase-Generator.git`
- Create a virtual environment `$ virtualenv venv ` ([click here](https://stackoverflow.com/questions/14604699/how-to-activate-virtualenv) to read about activating virtualenv)
- #### Activate virtualenv (Linux)
```sh
$ source ./venv/bin/activate
```
- #### Activate virtualenv (Windows)
```sh
$ cd venv/Scripts/
$ activate
```
- Install requirements and modules```sh
$ pip install -r requirements.txt
$ pip install -e .
```- Change directory to `tc_generator `
```sh
$ cd tc_generator/
```- **Edit the logic file of the language of your choice with the code for which you want to generate TCs**
NOTE: Make sure to keep the classname as '_logic_' in java so that it can compile to '_logic.class_'
- **Edit the Input area in `tc_gen.py` according to the input format you wish to generate**
- Run the project```sh
$ python tc_gen.py
```- Enter your choice of language when prompted
- Enter the choice of platform when prompted
- The input and output files would be generated and stored in `test-cases.zip` for HackerRank & HackerEarth and `test-cases` directory for CodeChef.**Tip:** If you're creating testcases for [CodeChef](https://codechef.com) then you can validate that the input sequence is generated according to the constraints using [this validator file](https://gist.github.com/thepushkarp/214402befde421b052443c0560991621). 😉
## How it Works ? 🤔
![Demo](demo3.gif)
## Setup using Docker 🐳
```sh
docker build . --tag=tcgen
docker run -p 4000:80 tcgen
```## Running Tests ✅
- Change Directory to `Testcase-Generator`
```sh
$ cd Testcase-Generator/
```- Install requirements and modules
```sh
$ pip install -r requirements.txt
$ pip install -e .
```- Run `pytest`
```sh
$ pytest
```- If no tests fail, the generator is working correctly.
# FAQ 📃
1. **How do I compile with a different version of C++?**
Changing Line 22 in [`lang_compiler.py`](https://github.com/aashutoshrathi/Testcase-Generator/blob/master/tc_generator/lang_compiler.py) to the line below will compile the file with C++ 17. You can replace the '17' with '11', '14' or '20' in the line below to compile with the respective versions.```py
'compile': ['g++', f'{CMD}.cpp', '-o', CMD, '-std=c++17']},
```1. **What line ending does it saves the testcases in?**
It saves the files with Linux style file endings (LF) in both Linux and Windows (unless the file is opened and saved again in WIndows that may change it to CRLF).# Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Aashutosh Rathi
🔧 📆 👀 🐛 💻
Pushkar Patel
🚧 ⚠️ 🐛 💻
Pritha Upadhyay
🚧 ⚠️ 🐛 💻
Vishnu Ramana
📖
Tim Rossback
📖
Sasivarnan R
📖
Gerardo Gálvez
💻
Dastgir
📖
Sai Adarsh S
📖
Rounak Agarwal
💻 📝
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
# Stargazers over time 📈
[![Star History Chart](https://api.star-history.com/svg?repos=aashutoshrathi/Testcase-Generator&type=Date)](https://star-history.com/#aashutoshrathi/Testcase-Generator&Date)
Made with ❤ by Aashutosh Rathi