首页 > 解决方案 > BDD 在本地工作,但在带有 Alpine Linux 的 GitLab Pipeline 中不起作用

问题描述

我的带有负面测试的场景方案失败了,但是当我在本地运行时它们通过了。根据我的 BDD,无效访问的系统消息是葡萄牙语,但我收到的是英语。预期:“登录/Senha incorreto”得到:“访问被拒绝:凭据无效。”

My code in file: .gitlab-cy.yml
before_script: 
 - chmod +x alpine.sh
 - ./alpine.sh
 - gem install bundler --no-document

image: ruby:alpine

test:
  stage: test
  script:
  - bundle install
  - bundle exec cucumber
  
code file alpine.sh
echo "http://dl-4.alpinelinux.org/alpine/v3.9/main" >> /etc/apk/repositories && \
echo "http://dl-4.alpinelinux.org/alpine/v3.9/community" >> /etc/apk/repositories 

apk update && \
    apk add build-base \
    libxml2-dev \
    libxslt-dev \
    curl unzip libexif udev chromium chromium-chromedriver wait4ports xvfb xorg-server dbus ttf-freefont mesa-dri-swrast \
    && rm -rf /var/cache/apk/*

message error pipeline gitlab
Scenario: Logar com credenciais invalidas
The results is: ✗
----------------------------------------------
      |   tester    |    1234     |  Login/Senha incorreto |  
  
  ----------------------------------------------, Reason:, 
  expected: "Login/Senha incorreto"
       got: "Access Denied: Invalid credentials."
  
  (compared using eql?)
  , ----------------------------------------------
      
      expected: "Login/Senha incorreto"
           got: "Access Denied: Invalid credentials."
      
      (compared using eql?)
       (RSpec::Expectations::ExpectationNotMetError)
      ./features/step_definitions/login.rb:22:in `block (2 levels) in <top (required)>'
      ./features/step_definitions/login.rb:20:in `nil'
      features/specs/login.feature:18:14:in `ele visualiza a mensagem de alerta "Login/Senha incorreto"'
true
Results:

标签: rubyautomated-testsgitlab-cipipelinealpine

解决方案


您应该尝试使用以下命令强制操作系统语言:

export LANG=C

或者

export LC_ALL=C

en_US.UTF-8或类似的。

所以在你的用例中:

before_script: 
 - chmod +x alpine.sh
 - export LC_ALL=C
 - ./alpine.sh
 - gem install bundler --no-document

或者

test:
  stage: test
  script:
  - export LC_ALL=C
  - bundle install
  - bundle exec cucumber

通过查看您提供的输出,我无法理解哪个块以错误结尾。


推荐阅读