我正在尝试开发一个用于web自动化测试的应用程序,它可以生成一个html报告。它在本地工作,但当试图将其停靠时,我遇到了麻烦。
这是dockerfile中最重要的一行(我认为)
CMD ["pytest", "--html=report.html", "tests/test_your_info_page.py"]最终目标是在创建容器时开始测试。但是'report.html‘文件似乎没有生成
docker文件的其余部分如下所示
FROM python:3.9 AS webautomation
# install google chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
RUN apt-get -y update
RUN apt-get install -y google-chrome-stable
# install chromedriver
RUN apt-get install -yqq unzip
RUN wget -O /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`/chromedriver_linux64.zip
RUN unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/
# set display port to avoid crash
ENV DISPLAY=:99
COPY requirements.txt .
RUN pip install -r requirements.txt
WORKDIR .
COPY . .
CMD ["pytest", "--html=report.html", "tests/test_your_info_page.py"]
FROM nginx:alpine
COPY --from=webautomation . /usr/share/nginx/htmlrequirements.txt看起来像是
pytest==6.2.2
selenium==3.141.0
pytest-html==3.1.1项目结构
-tests
-test_your_info_page.py发布于 2021-03-30 22:50:15
问题似乎与多阶段构建有关。删除FROM nginx后,我现在可以在docker容器中运行pytest了。
更新
使用docker cp命令,我可以复制在本地计算机上生成的报告并在浏览器中查看它
https://stackoverflow.com/questions/66857397
复制相似问题