Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertions in IntegrationTest sessions incorrectly reported #32142

Closed
sambostock opened this issue Feb 28, 2018 · 0 comments · Fixed by #32143
Closed

Assertions in IntegrationTest sessions incorrectly reported #32142

sambostock opened this issue Feb 28, 2018 · 0 comments · Fixed by #32143

Comments

@sambostock
Copy link
Contributor

Assertions run inside a separate session in ActionDispatch::IntegrationTest are not counted in the test report.

Steps to reproduce

TL;DR

Running this test

class TLDRTest < ActionDispatch::IntegrationTest
  test('assert in session') { open_session.assert(true) }
end

reports an incorrect number of assertions

# Running:

.

Finished in 0.001477s, 677.0481 runs/s, 0.0000 assertions/s.
-1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
+1 runs, 0 assertions, 0 failures, 0 errors, 0 skips
Full Test
#! /usr/bin/env ruby
# frozen_string_literal: true

begin
  require "bundler/inline"
rescue LoadError => e
  $stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
  raise e
end

gemfile(true) { gem 'rails', '5.1.5', source: 'https://rubygems.org' }
require 'rails/all'
require "minitest/autorun"

class AssertionTest < ActionDispatch::IntegrationTest
  test('assert outside session') { assert(true) } # control
  test('assert in session') { open_session.assert(true) }
end

class BugTest < Minitest::Test
  def test_control
    test_instance = AssertionTest.new('test_assert_outside_session').run
    refute_predicate test_instance.assertions, :zero?
  end

  def test_actual
    test_instance = AssertionTest.new('test_assert_in_session').run
    refute_predicate test_instance.assertions, :zero?
  end
end

Expected behavior

The assertions in sessions should be counted in the test report.

Actual behavior

The assertions in sessions are not counted in the test report.

System configuration

Rails version: 5.1.5

Ruby version: 2.4.2


cc. @aud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants