我的 flutter 项目中有几个测试文件,使用 flutter test
在本地运行这些文件没有任何错误消息。但是在以以下错误消息结尾的 docker 映像上运行相同的测试:
The following StateError was thrown running a test:
Bad state: No element
我不确定此错误消息的原因是项目本身还是我的 Dockerfile
FROM ubuntu:16.04
ENV FLUTTER_VERSION="1.22.6"
RUN apt update -y
RUN apt install -y \
git \
wget \
curl \
unzip \
lcov \
lib32stdc++6
ENV FLUTTER_ROOT="/opt/flutter"
RUN git clone --branch $FLUTTER_VERSION --depth=1 https://github.com/flutter/flutter "${FLUTTER_ROOT}"
ENV PATH="${FLUTTER_ROOT}/bin:${PATH}"
RUN flutter config --no-analytics
RUN flutter precache
RUN yes "y" | flutter doctor --android-licenses
RUN flutter doctor -v
ENV PATH $PATH:/flutter/bin/cache/dart-sdk/bin:/flutter/bin
WORKDIR /opt/app
COPY . .
RUN flutter pub get
RUN flutter test