Skip to content

Commit 3fd3cb5

Browse files
Merge branch 'main' into coverup-thyself
2 parents f7e5b88 + fdb7582 commit 3fd3cb5

18 files changed

+886
-404
lines changed

CoverUp-arxiv-2403.16218.pdf

417 KB
Binary file not shown.

README.md

+18-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
<!--
12
<img src="images/logo.png?raw=True" align="right" width="20%"/>
2-
3-
# CoverUp: Automatically Generating Higher-Coverage Test Suites with AI
3+
# CoverUp: Automatically Generating Higher-Coverage Test Suites with AI !
4+
-->
5+
<img src="images/logo-with-title.png?raw=True" align="right" width="100%"/>
46

57
by [Juan Altmayer Pizzorno](https://jaltmayerpizzorno.github.io) and [Emery Berger](https://emeryberger.com)
68
at UMass Amherst's [PLASMA lab](https://plasma-umass.org/).
@@ -19,36 +21,41 @@ To generate tests, it first measures your suite's coverage using [SlipCover](htt
1921
It then selects portions of the code that need more testing (that is, code that is uncovered).
2022
CoverUp then engages in a conversation with an [LLM](https://en.wikipedia.org/wiki/Large_language_model),
2123
prompting for tests, checking the results to verify that they run and increase coverage (again using SlipCover), and re-prompting for adjustments as necessary.
22-
Finally, CoverUp checks that the new tests integrate well, attempting to resolve any issues it finds.
24+
Finally, CoverUp optionally checks that the new tests integrate well, attempting to resolve any issues it finds.
2325

24-
## Installing CoverUp
26+
For technical details and a complete evaluation, see our arXiv paper, [_CoverUp: Coverage-Guided LLM-Based Test Generation_](https://arxiv.org/abs/2403.16218) ([PDF](https://github.com/plasma-umass/CoverUp/blob/main/CoverUp-arxiv-2403.16218.pdf)).
2527

28+
## Installing CoverUp
2629
CoverUp is available from PyPI, so you can install simply with
2730
```shell
2831
$ python3 -m pip install coverup
2932
```
3033

31-
Currently, CoverUp requires an [OpenAI account](https://platform.openai.com/signup) to run (we plan to support local models in the near future).
32-
Your account will also need to have a [positive balance](https://platform.openai.com/account/usage).
33-
Create an [API key](https://platform.openai.com/api-keys) and store its "secret key" (usually a
34+
### LLM model access
35+
CoverUp can be used with OpenAI, Anthropic or AWS Bedrock models; it requires that the
36+
access details be defined as shell environment variables: `OPENAI_API_KEY`,
37+
`ANTHROPIC_API_KEY` or `AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY`/`AWS_REGION_NAME`, respectively.
38+
39+
For example, for OpenAI you would create an [account](https://platform.openai.com/signup), ensure
40+
it has a [positive balance](https://platform.openai.com/account/usage) and then create an
41+
an [API key](https://platform.openai.com/api-keys), storing its "secret key" (usually a
3442
string starting with `sk-`) in an environment variable named `OPENAI_API_KEY`:
3543
```shell
3644
$ export OPENAI_API_KEY=<...your-api-key...>
3745
```
3846

3947
## Using CoverUp
40-
41-
If your module's source code is in `src` and your tests in `tests`, you can run CoverUp as
48+
If your module is named `mymod`, its sources are under `src` and the tests under `tests`, you can run CoverUp as
4249
```shell
43-
$ coverup --source-dir src --tests-dir tests
50+
$ coverup --source-dir src/mymod --tests-dir tests
4451
```
4552
CoverUp then creates tests named `test_coverup_N.py`, where `N` is a number, under the `tests` directory.
4653

4754
### Example
4855

4956
Here we have CoverUp create additional tests for the popular package [Flask](https://flask.palletsprojects.com/):
5057
```
51-
$ coverup --source-dir src/flask --tests-dir tests
58+
$ coverup --source-dir src/flask --tests-dir tests --disable-polluting --no-isolate-tests
5259
Measuring test suite coverage... starting coverage: 90.2%
5360
Prompting gpt-4-1106-preview for tests to increase coverage...
5461
100%|███████████████████████████████████████████████████| 95/95 [02:49<00:00, 1.79s/it, usage=~$3.30, G=51, F=141, U=22, R=0]

images/comparison.png

-224 Bytes
Loading

images/logo-with-title.png

212 KB
Loading

pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ dependencies = [
2222
"tiktoken",
2323
"aiolimiter",
2424
"tqdm",
25-
"llm_utils",
26-
"slipcover>=1.0.3",
25+
"slipcover>=1.0.8",
26+
"pytest-forked",
2727
"litellm>=1.33.1"
2828
]
2929

src/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CoverUp.egg-info

0 commit comments

Comments
 (0)