Comments (9)
Found the issue. For future google searches.
GOOD
Allure.add_attachment(
name: filename,
source: File.open("screenshots/#{filename}.png"),
type: Allure::ContentType::PNG,
test_case: true
)
BAD
Allure.add_attachment(
name: filename,
source: "/path/to/file",
type: Allure::ContentType::PNG,
test_case: true
)
Source must be a File object for the PNG, JPG case. I though that I needed to send the path for the source file.
from allure-ruby.
Thanks for the issue. I will have to check out the order how rspec executes hooks. It's possible that allure test object is already finalised when this hook is executed.
from allure-ruby.
@andreiaionitoaiesv
I actually couldn't reproduce the issue. You can check the example here, attachments are added fine.
Also, just noticed that you state to be using different versions for commons and allure-rspec. You should be using same version and technically You do not need to require allure-ruby-commons, it is a dependency of allure-rspec.
from allure-ruby.
Closing, not reproducible with latest 2.13.3 version
from allure-ruby.
I just cloned the repository from here
` undefined method `steps' for nil:NilClass`
So I've tried different stuff and I can't make this to work. Can you please provide a working example?
from allure-ruby.
After a quick look I've noticed that the current_executable seems to be nil. I did not have the chance to dig deeper, but correct me if I'm wrong it seems as you said initially that It's possible that allure test object is already finalised when this hook is executed.
from allure-ruby.
How exactly You rspec runner is configured?
Here is the output of test run if executed via rake task like it is mentioned in README:
❯ bundle exec rake test
test_feature
test_case_1 (FAILED - 1)
must be pending example (PENDING: Not yet implemented)
must be pending example 2 (PENDING: Not yet implemented)
Some usecase 2
10 cannot be greater than 19 (FAILED - 2)
4 must not be equal to 5 (FAILED - 3)
should pass
Some usecase 1
should have some steps (FAILED - 4)
string 'aaa' cannot be equal to string 'bbb' (FAILED - 5)
must be broken test case (FAILED - 6)
Some usecase 4
10 cannot be greater than 19 (FAILED - 7)
4 must not be equal to 5 (FAILED - 8)
Some usecase 3
10 cannot be greater than 19 (FAILED - 9)
4 must not be equal to 5 (FAILED - 10)
Pending: (Failures listed here are expected and do not affect your suite's status)
1) test_feature must be pending example
# Not yet implemented
# ./spec/test_feature_0/test_case_1_spec.rb:16
2) test_feature must be pending example 2
# Not yet implemented
# ./spec/test_feature_0/test_case_1_spec.rb:18
Failures:
1) test_feature test_case_1
Failure/Error: expect(10).to be > 19
expected: > 19
got: 10
# ./spec/test_feature_0/test_case_1_spec.rb:12:in `block (3 levels) in <top (required)>'
# ./spec/test_feature_0/test_case_1_spec.rb:11:in `block (2 levels) in <top (required)>'
2) Some usecase 2 10 cannot be greater than 19
Failure/Error: expect(10).to be > 19
expected: > 19
got: 10
# ./spec/test_feature_1/some_other_spec.rb:7:in `block (2 levels) in <top (required)>'
3) Some usecase 2 4 must not be equal to 5
Failure/Error: expect(5).to eq(4)
expected: 4
got: 5
(compared using ==)
# ./spec/test_feature_1/some_other_spec.rb:11:in `block (2 levels) in <top (required)>'
4) Some usecase 1 should have some steps
Failure/Error: expect(0).to eq(1)
expected: 1
got: 0
(compared using ==)
# ./spec/test_feature_1/some_steps_spec.rb:18:in `block (3 levels) in <top (required)>'
# ./spec/test_feature_1/some_steps_spec.rb:17:in `block (2 levels) in <top (required)>'
5) Some usecase 1 string 'aaa' cannot be equal to string 'bbb'
Failure/Error: expect('aaa').to eq('bbb')
expected: "bbb"
got: "aaa"
(compared using ==)
# ./spec/test_feature_1/some_steps_spec.rb:23:in `block (2 levels) in <top (required)>'
6) Some usecase 1 must be broken test case
Failure/Error: raise 'Unexpected exception'
RuntimeError:
Unexpected exception
# ./spec/test_feature_1/some_steps_spec.rb:27:in `block (2 levels) in <top (required)>'
7) Some usecase 4 10 cannot be greater than 19
Failure/Error: expect(10).to be > 19
expected: > 19
got: 10
# ./spec/test_feature_2/some_fourth_spec.rb:7:in `block (2 levels) in <top (required)>'
8) Some usecase 4 4 must not be equal to 5
Failure/Error: expect(5).to eq(4)
expected: 4
got: 5
(compared using ==)
# ./spec/test_feature_2/some_fourth_spec.rb:11:in `block (2 levels) in <top (required)>'
9) Some usecase 3 10 cannot be greater than 19
Failure/Error: expect(10).to be > 19
expected: > 19
got: 10
# ./spec/test_feature_2/some_third_spec.rb:7:in `block (2 levels) in <top (required)>'
10) Some usecase 3 4 must not be equal to 5
Failure/Error: expect(5).to eq(4)
expected: 4
got: 5
(compared using ==)
# ./spec/test_feature_2/some_third_spec.rb:11:in `block (2 levels) in <top (required)>'
Finished in 0.05041 seconds (files took 0.26706 seconds to load)
13 examples, 10 failures, 2 pending
Failed examples:
rspec ./spec/test_feature_0/test_case_1_spec.rb:6 # test_feature test_case_1
rspec ./spec/test_feature_1/some_other_spec.rb:6 # Some usecase 2 10 cannot be greater than 19
rspec ./spec/test_feature_1/some_other_spec.rb:10 # Some usecase 2 4 must not be equal to 5
rspec ./spec/test_feature_1/some_steps_spec.rb:6 # Some usecase 1 should have some steps
rspec ./spec/test_feature_1/some_steps_spec.rb:22 # Some usecase 1 string 'aaa' cannot be equal to string 'bbb'
rspec ./spec/test_feature_1/some_steps_spec.rb:26 # Some usecase 1 must be broken test case
rspec ./spec/test_feature_2/some_fourth_spec.rb:6 # Some usecase 4 10 cannot be greater than 19
rspec ./spec/test_feature_2/some_fourth_spec.rb:10 # Some usecase 4 4 must not be equal to 5
rspec ./spec/test_feature_2/some_third_spec.rb:6 # Some usecase 3 10 cannot be greater than 19
rspec ./spec/test_feature_2/some_third_spec.rb:10 # Some usecase 3 4 must not be equal to 5
❯ allure serve report/allure-results
Generating report to temp directory...
Report successfully generated to /var/folders/hb/x8g3t9c93_v6_c_7lz02rl3m0000gn/T/1863617268208488389/allure-report
Starting web server...
2020-02-05 18:22:52.811:INFO::main: Logging initialized @2339ms to org.eclipse.jetty.util.log.StdErrLog
Server started at <http://192.168.1.114:49681/>. Press <Ctrl+C> to exit
Make sure whatever executes rspecs is correctly configured, all the gems are up to date, and ruby version is > 2.5.
Current executable can be nil
, if you try to add step before the test suite was even started. My original assumption was wrong, it checked it out and hooks are handled correctly.
from allure-ruby.
Thanks. I kinda got it to work. But the attachments are broken. For the PNG type:
Any idea why this is happening? Here is the spec helper.
Allure.add_attachment( name: filename, source: "./screenshots/#{filename}.png", type: Allure::ContentType::PNG, test_case: true )
The path and filename are correct. I'm a little confused about the
def prepare_attachment(name, type) extension = ContentType.to_extension(type) || return file_name = "#{UUID.generate}-attachment.#{extension}" Attachment.new(name: name, source: file_name, type: type) end
I would expect that the add_attachment method just to copy and attach the specified files. But apparently in prepare_attachment you create a new file. Please correct if I'm wrong.
from allure-ruby.
It does copy a file, it happens here:
If you want to copy an existing file, it has to be an actual File
object, not just a path as string.
from allure-ruby.
Related Issues (20)
- Tags are empty for rspec tests HOT 3
- Output override is not working in 2.13.10 HOT 5
- Support for rspec-retry HOT 2
- Same test case goes for a retry section even though being specified with custom environment HOT 2
- Suites names are not displayed HOT 5
- Could not update to version greater than 2.13.6 HOT 6
- Allure 2.13.6.4 and above outputs hash instead of json HOT 7
- [Security] Workflow test.yml is using vulnerable action paambaati/codeclimate-action HOT 1
- Add support for parameters in step HOT 3
- allure step doesn't work if is used in global before :all hook HOT 11
- Not able to generate report in github workflows HOT 2
- On expected error Step is not stoped with Failed state HOT 1
- Use monotonic clock HOT 4
- JRuby Compatibility HOT 2
- Add support for influencing history id based on environment properties HOT 8
- Allure Report shows incorrect calculations for failed tests because of test retries HOT 2
- [allure-cucumber] Inconsistent step and test status if not using RSpec HOT 1
- Enable terminal output of test results when using AllureRspecFormatter HOT 2
- bug: undefined method `failure_exception=' HOT 1
- NameError: uninitialized constant AllureRspec::Adaptor HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from allure-ruby.