2

I have a suite of tests that I run, but would like to ignore a few tests locally, since they require a Java version that is different and consistently fail in my environment. I'm okay with ignoring these tests (we have integrated testing anyways)

How can I specify to Rails to not run certain tests but run all others? I'm just tired of seeing the errors, and it could lead me to miss some legit test failures...

Any help would be appreciated!

2
  • Which testing framework are you using? Commented Aug 19, 2015 at 0:00
  • Sorry Ryan, this is for RSpec, also was hoping to only do this for my local environment (since our tests are in source control) Commented Aug 19, 2015 at 15:56

2 Answers 2

3

In RSpec one can use exclusion filters and then from the command line, skip specific tests.

In your case, tag the description blocks as java: true.

describe "code for JVM in production", java: true do
  it "java-specific test" do
  end
end

Then run rspec . --tag ~java:true RSpec will ignore/skip the tests matching java: true tag.

NOTE: It is not necessary to set the other tests to java: false

Alternatively, you can amend your spec_helper.rb with a configuration to skip these tests when run locally using an environment variable.

RSpec.configure do |c|
  if RUBY_PLATFORM.include?('darwin') # assumes Macintosh
    c.filter_run_excluding java: true
  end
end

CITE:

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks @scarver2, but I was hoping to do this locally since our tests are all in source control, any idea how I could ignore the tests in my local machine?
@MarkKadlec Thank you for the additional info. I completely changed my answer to cater to RSpec. RSpec provides an excellent mechanism for skipping tests that match specific tags.
that's a great answer, thanks, I'm going to implement the spec_helper.rb method!
1

Use the if or unless conditional in the describe or context block.

@scarver2's answer is really great and I just wanted to add a more lightweight alternative as well.

You can also use the if or unless conditional in the describe or context block, like:

describe "code for JVM in production", unless: RUBY_PLATFORM.include?('darwin') do
  it "java-specific test" do
  end
end

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.