Allure-rspec - 无法在HTML报告中查看任何数据

时间:2017-05-15 11:37:11

标签: ruby rspec allure

这是@tourdedave的示例代码

require 'allure-rspec'
require 'selenium-webdriver'
require 'uuid'

RSpec.configure do |config|
  config.include AllureRSpec::Adaptor

  config.before(:each) do
    @driver = Selenium::WebDriver.for :firefox
  end

  config.after(:each) do |example|
    if example.exception
      example.attach_file('screenshot', File.new(
          @driver.save_screenshot(
              File.join(Dir.pwd, "results/#{UUID.new.generate}.png"))))
    end

    @driver.quit
  end
end

AllureRSpec.configure do |config|
  config.output_dir = 'results'
  config.clean_dir = true # this is the default value
end

describe "Reporting" do
  it 'passes' do
    @driver.get 'http://the-internet.herokuapp.com'
    expect(true).to eql true
  end

  it 'fails' do
    @driver.get 'http://the-internet.herokuapp.com'
    expect(true).to eql false
  end
end

这是xml生成的

<?xml version="1.0"?>
<ns2:test-suite xmlns="" xmlns:ns2="urn:model.allure.qatools.yandex.ru" start="1494847050271" stop="1494847071452">
  <name>Reporting</name>
  <title>Reporting</title>
  <test-cases>
    <test-case start="1494847050271" stop="1494847060326" status="passed">
      <name>Reporting passes</name>
      <title>Reporting passes</title>
      <steps/>
      <attachments/>
      <labels>
        <label name="thread" value="7049420"/>
        <label name="host" value="shop-Lenovo-B40-80"/>
      </labels>
      <parameters/>
    </test-case>
    <test-case start="1494847060327" stop="1494847071451" status="failed">
      <name>Reporting fails</name>
      <title>Reporting fails</title>
      <failure>
        <message>
expected: false
     got: true

(compared using eql?)
</message>
        <stack-trace>/var/lib/gems/2.3.0/gems/rspec-support-3.6.0/lib/rspec/support.rb:87:in `block in &lt;module:Support&gt;'&#xD;
/var/lib/gems/2.3.0/gems/rspec-support-3.6.0/lib/rspec/support.rb:96:in `notify_failure'&#xD;
/var/lib/gems/2.3.0/gems/rspec-expectations-3.6.0/lib/rspec/expectations/fail_with.rb:35:in `fail_with'&#xD;
/var/lib/gems/2.3.0/gems/rspec-expectations-3.6.0/lib/rspec/expectations/handler.rb:38:in `handle_failure'&#xD;
/var/lib/gems/2.3.0/gems/rspec-expectations-3.6.0/lib/rspec/expectations/handler.rb:50:in `block in handle_matcher'&#xD;
/var/lib/gems/2.3.0/gems/rspec-expectations-3.6.0/lib/rspec/expectations/handler.rb:27:in `with_matcher'&#xD;
/var/lib/gems/2.3.0/gems/rspec-expectations-3.6.0/lib/rspec/expectations/handler.rb:48:in `handle_matcher'&#xD;
/var/lib/gems/2.3.0/gems/rspec-expectations-3.6.0/lib/rspec/expectations/expectation_target.rb:65:in `to'&#xD;
/home/shop/Documents/allspark/spec/activities_spec.rb:58:in `block (2 levels) in &lt;top (required)&gt;'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example.rb:254:in `instance_exec'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example.rb:254:in `block in run'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example.rb:500:in `block in with_around_and_singleton_context_hooks'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example.rb:457:in `block in with_around_example_hooks'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/hooks.rb:464:in `block in run'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/hooks.rb:602:in `run_around_example_hooks_for'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/hooks.rb:464:in `run'&#xD;
/var/lib/gems/2.3.0/gems/allure-rspec-0.8.0/lib/allure-rspec/hooks.rb:33:in `run'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example.rb:457:in `with_around_example_hooks'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example.rb:500:in `with_around_and_singleton_context_hooks'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example.rb:251:in `run'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example_group.rb:627:in `block in run_examples'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example_group.rb:623:in `map'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example_group.rb:623:in `run_examples'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/example_group.rb:589:in `run'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:118:in `block (3 levels) in run_specs'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:118:in `map'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:118:in `block (2 levels) in run_specs'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/configuration.rb:1894:in `with_suite_hooks'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:113:in `block in run_specs'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/reporter.rb:79:in `report'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:112:in `run_specs'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:87:in `run'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:71:in `run'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:45:in `invoke'&#xD;
/var/lib/gems/2.3.0/gems/rspec-core-3.6.0/exe/rspec:4:in `&lt;top (required)&gt;'&#xD;
/usr/local/bin/rspec:22:in `load'&#xD;
/usr/local/bin/rspec:22:in `&lt;main&gt;'</stack-trace>
      </failure>
      <steps/>
      <attachments>
        <attachment source="1da194210e6a091af3ffb118c3d067cd629f58868d6a2695302b67a5fc3b25ad-attachment.png" title="screenshot" size="46323" type="image/png"/>
      </attachments>
      <labels>
        <label name="thread" value="7049420"/>
        <label name="host" value="shop-Lenovo-B40-80"/>
      </labels>
      <parameters/>
    </test-case>
  </test-cases>
  <labels>
    <label name="thread" value="7049420"/>
    <label name="host" value="shop-Lenovo-B40-80"/>
  </labels>
</ns2:test-suite>

我使用以下版本:

JAVA 8
allure-ruby-adaptor-api 0.7.0
allure-rspec 0.8.0
selenium-webdriver 3.2.2
allure -version 2.0.0
rspec -v                                                                                                                          
RSpec 3.6
  - rspec-core 3.6.0
  - rspec-expectations 3.6.0
  - rspec-mocks 3.6.0
  - rspec-support 3.6.0

我使用的命令是

allure serve 

&安培;

allure generate

我也在使用并行测试。 我得到一个诱惑报告文件夹,但生成的HTML是空的,没有测试结果。 我也尝试使用示例here但结果相同。

1 个答案:

答案 0 :(得分:3)

由于您将Allure输出目录更改为results,因此您还需要为Allure命令行指定结果目录:

$ allure generate path/to/results

$ allure serve path/to/results