Questions tagged [testunit]

Test-unit is a unit testing library in Ruby. It was part of the standard library in Ruby 1.8, and there's a compatibility layer in the standard library of Ruby 1.9.

Test-unit is a unit testing library in Ruby. It was part of the standard library in Ruby 1.8, and there's a compatibility layer in the standard library of Ruby 1.9.

Test::Unit (test-unit) is unit testing framework for Ruby, based on xUnit principles. These were originally designed by Kent Beck, creator of extreme programming software development methodology, for Smalltalk's SUnit. It allows writing tests, checking results and automated testing in Ruby.

366 questions
6
votes
1 answer

Why is my "boot time" of `rake test:units` on Rails 3.2.1 so slow?

We're developing an app on Ruby 1.9.3 and Rails 3.2.1. Recently, our unit tests have become sluggish at the beginning. It takes ~15 seconds for the invocations & executions to take place. Once I see "Execute test:units", it takes another 10…
makdad
  • 6,402
  • 3
  • 31
  • 56
6
votes
3 answers

Run multiple tests in one script in parallel using Ruby Test Unit

I have 4 tests in one ruby script, which I run using command ruby test.rb the out put looks like Loaded suite test Started .... Finished in 50.326546 seconds. 4 tests, 5 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0…
Amey
  • 8,470
  • 9
  • 44
  • 63
5
votes
2 answers

ArgumentError: assertion message must be String or Proc using assert_select

I'm writing a controller test for a rails 3.1 app using testunit 2.4.0. I want to assert that a certain heading does not appear on the page. I'm using assert_select like this: assert_select 'h1', {:text => /Key Dates/, :count => 0} and getting the…
heathd
  • 2,741
  • 2
  • 14
  • 5
5
votes
3 answers

Missing progress dots and 0% passed in rails test output (Test Unit, Rails 3.1 rc6, Ruby 1.9.2)

My tests all pass and my results look like this: Started Finished in 361.988408 seconds. 479 tests, 1017 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 0% passed Why don't I see the usual progress dots I used to see in…
Nico
  • 881
  • 1
  • 6
  • 19
5
votes
3 answers

running Rails unit tests without loading the environment or using a database

As something of an academic exercise, I thought I'd try to get my unit tests running without loading the Rails env (or hitting the database). I've seen this done before, and it seems like folks talk about it enough, but I can't find any good/current…
whatbird
  • 1,552
  • 1
  • 14
  • 25
5
votes
1 answer

How to test the opposite of assert_text in Ruby on Rails

I want to be sure my page does not contain certain text, I know there is an assert_text function, but, how do I test the opposite? I am using RoR 6.0, the default test framework (I think it is Test Unit) and capybara
Alejo Dev
  • 2,290
  • 4
  • 29
  • 45
5
votes
1 answer

Error when using 'omit' feature in Test Unit 2.3.0

I'm a bit stumped by my issue. I am using ruby 1.8.7, rails 2.3.2. I am attempting to using the 'omit' feature in Test Unit 2.3.0. Here is my test: def test_create_reward_program omit("Pending") reward_program =…
Juan
  • 89
  • 4
5
votes
1 answer

What's the best strategy for adding tests to an existing rails project?

There is an existing project that is already deployed in production. We want to add some tests on it (the sooner the better) and I have to choose between going the BDD way (rspec/cucumber) or the TDD way (TestUnit). I am really starting with BDD and…
Amokrane Chentir
  • 29,907
  • 37
  • 114
  • 158
5
votes
3 answers

Jest running tests by specific path

currently I am using the standard testRegex logic to run my tests "jest": { "moduleFileExtensions": [ "ts", "js" ], "transform": { "^.+\\.ts?$": "/node_modules/ts-jest/preprocessor.js", "^.+\\.js?$":…
user762579
5
votes
4 answers

Undefined method: assert_not_nil in Minitest

I'm trying to execute the following code, but it is giving me an undefined method error: require 'minitest/autorun' require 'string_extension' class StringExtensionTest < Minitest::Test def test_humanize_returns_nothing assert_not_nil…
Arslan Ali
  • 17,418
  • 8
  • 58
  • 76
5
votes
4 answers

How do I mock or override Kernel.system?

How would be the correct way to mock or override the Kernel.system method so that when called with: system("some command") instead of executing the command, it executes some predefined code? I tried adding the following to my Test class: module…
obaqueiro
  • 982
  • 12
  • 29
5
votes
1 answer

Running RSpec With Existing TestUnit tests and coverage with Simplecov

I'm new to ROR and wondering if Simplecov provides tests coverage for both TestUnit and RSpec tests in the same project? I am in the process of migrating some tests we wrote in RSpec from a standalone webapp to an existing webapp that currently uses…
claritee
  • 61
  • 5
4
votes
3 answers

Capybara issue: @request must be an ActionDispatch::Request

I'm having problems making Capybara work with Rails. Just testing that suposedly interesting test thing. OK, in the attached code there are a couple of equivalent tests. The first one is made with shoulda-context + Test::Unit that comes with Rails. …
marcel massana
  • 367
  • 3
  • 11
4
votes
1 answer

how to write and inherit from an abstract subclass of ActionController::TestCase

I have a bunch of Rails 3.1 controllers which all have very similar testing requirements. I have extracted out the common code (all Test::Unit style), e.g. the following three tests are completely reusable across all of them: def create …
Adam Spiers
  • 17,397
  • 5
  • 46
  • 65
4
votes
1 answer

What makes a good failure message for testunit or other nunit style frameworks?

In Ruby's test/unit, and other such nunit style frameworks, what makes a good failure message? Should the failure message merely describe how the expected value does not match the expected value? assert_match("hey", "hey this is a test", "The word…
Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338