我试图在travis-ci(持续集成平台)中测试一个简单的菜单算法,等待用户输入执行任务 (CRUD) 像:
显示,添加,删除,更新注册表或退出。
以下是示例代码:
这是我的.travis.yml文件:
language: python
python:
- "2.6"
- "2.7"
- "3.2"
- "3.3"
- "3.4"
- "3.5"
- "3.5-dev" # 3.5 development branch
- "nightly" # currently points to 3.6-dev
# command to install dependencies
# install: "pip install -r requirements.txt"
# command to run tests
script:
- python 1aula_agenda.py
这是travis-ci.org的输出:
0.00s$ source ~/virtualenv/python2.7/bin/activate
$ python --version
Python 2.7.9
$ pip --version
pip 6.0.7 from /home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages (python 2.7)
Could not locate requirements.txt. Override the install: key in your .travis.yml to install dependencies.
$ python 1aula_agenda.py
0. Visualizar
1. Inserir um contato
2. Remover um contato
3. Alterar um contato
4. Sair do programa
Escolha uma opcao:
No output has been received in the last 10 minutes, this potentially indicates a stalled build or something wrong with the build itself.
The build has been terminated
我该怎么做travis测试所有选项 0 , 1 , 2 , 3 , 4 并在选项1和3的情况下添加名称和数字?
答案 0 :(得分:5)
可以使用电池测试创建文件testing.txt
,以测试程序的功能。
testing.txt
包含程序所需的键盘输入。
例如,测试你的例子
0
1
"John Smith"
"1235-5387"
0
4
并在.travis.yml文件中包含testing.txt:
language: python
python:
- "2.6"
- "2.7"
- "3.2"
- "3.3"
- "3.4"
- "3.5"
- "3.5-dev" # 3.5 development branch
- "nightly" # currently points to 3.6-dev
# command to install dependencies
# install: "pip install -r requirements.txt"
# command to run tests
script:
- python 1aula_agenda.py < testing.txt