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
8
votes
3 answers

In Ruby, how to I control the order in which Test::Unit tests are run?

For example, when these tests are run, I want to ensure that test_fizz always runs first. require 'test/unit' class FooTest < Test::Unit::TestCase def test_fizz puts "Running fizz" assert true end def test_bar …
FMc
  • 41,963
  • 13
  • 79
  • 132
8
votes
4 answers

rake:test not running custom tests in subdirectory

I'm using Rails 4.0.0.beta1. I added two directories: app/services and test/services. I also added this code, based on reading testing.rake of railties: namespace :test do Rake::TestTask.new(services: "test:prepare") do |t| t.libs << "test" …
David J.
  • 31,569
  • 22
  • 122
  • 174
7
votes
3 answers

Guard + spork + Rspec issue - How do I remove hooks to Test::Unit?

I have guard-spork running on my rails 3.2.11 project on Ubuntu 12.04. I got my configuration from railstutorial.org. Spork starts, then guard says it can't find spork to start, waits 30 secs, then 60 secs, then works. It works, but starts up with…
Dan Williams
  • 3,769
  • 1
  • 18
  • 26
7
votes
1 answer

How do I use Capybara to test that a form element is disabled when using jQuery's prop method?

In my Rails 3 app, I've been using jQuery's attr() method to do things like this: $('#application_dust_type_id').attr('disabled', 'disabled'); I would use Test/Unit, capybara and capybara-webkit to test this with: assert page.has_selector?…
croceldon
  • 4,511
  • 11
  • 57
  • 92
6
votes
1 answer

Mock a Active Record abstract class and how to stub a nil object in rails test::unit/mocha?

i have two question 1.How do i stub a nil object in rails test cases. 2.Mock an Active Record Abstract class I have a application X with a test database X_test, Now i need to stub an database y_test which doesn't exist and which implements Active…
yednamus
  • 582
  • 1
  • 4
  • 22
6
votes
1 answer

How can I get color output in autotest using Test/Unit, MiniTest?

Rails 3.2.1 app, using the minitest and autotest-rails gems. If I run "rake test" the output is in color. But if I run autotest, the output is not in color. How can I get color output when using autotest? Here's my…
croceldon
  • 4,511
  • 11
  • 57
  • 92
6
votes
2 answers

Ruby on Rails: Best way to test a failed call to a third party API

I call a third party web service right now as part of my application. I am using the RestClient gem in order to do this. There are a ton of tools available to do the same thing, so that should not matter. What I'm curious about is having good enough…
randombits
  • 47,058
  • 76
  • 251
  • 433
6
votes
2 answers

can't get test unit startup to work in ruby 1.9.2

I am using Ruby 1.9.2 (ruby -v yields :ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]), and I am trying to get this to work: require 'test/unit' class TestStartup < Test::Unit::TestCase def self.startup puts "startup" end def…
user119282
  • 337
  • 4
  • 12
6
votes
1 answer

How to test Ruby scripts which offer functionality between runs?

What's a good method for unit testing which test a script's ability to maintain correct data between executions--after a script is terminated with Ctrl-C and then re-run? Are there any tests for existing modules or scripts that do something similar…
sutch
  • 1,225
  • 1
  • 13
  • 28
6
votes
2 answers

ruby test unit gem doesn't show dots for passed test

Ruby test unit gem doesn't show dots for passed test. I'm running on Ubuntu 11.04 . It shows 'E' and 'F' for failure, but nothing for pass. This problem dissapears if I comment gem 'test-unit' line, but in that case test-unit 2.x features (like…
m.silenus
  • 492
  • 7
  • 15
6
votes
1 answer

Rails 3 Capybara error

I'm trying to get Capybara to work with rails 3 (and test unit) but when I try to run rake test:integration I get an error:ArgumentError: @request must be an ActionDispatch::Request The test: require 'integration_test_helper' class UserNotesTest <…
errorhandler
  • 1,757
  • 3
  • 22
  • 29
6
votes
1 answer

Test tasks missing from rake: rake aborted! Don't know how to build task 'test:units'

I created a Rails 4 app recently and for some reason my rake tasks don't include test. Here's some console action to demonstrate the problem: > rake test:units rake aborted! Don't know how to build task 'test:units' …
clozach
  • 5,118
  • 5
  • 41
  • 54
6
votes
2 answers

Can't execute localStorage.clear in teardown method of a Capybara test

I'm using Capybara to test the front-end portion of an app that utilizes HTML5 local storage to persist data values on the client. In order to ensure session data from one test doesn't interfere with another, I made sure to call…
6
votes
4 answers

How to include unit tests in a ruby module?

I'm trying to include the unit tests for a module in the same source file as the module itself, following the Perl modulino model. #! /usr/bin/env ruby require 'test/unit' module Modulino def modulino_function return 0 …
philant
  • 34,748
  • 11
  • 69
  • 112
6
votes
1 answer

how do you assert an exception from another ruby module is thrown? (using assert_throws)

I'm trying to write code like this: assert_throws(:ExtractionFailed) { unit.extract_from('5 x 2005')} ExtractionFailed is a trivial subclass of Exception, and under test/unit, I'm trying to assert that it is thrown when I call unit.extract_from(...…
Dafydd Rees
  • 6,941
  • 3
  • 39
  • 48
1 2
3
24 25