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
15
votes
7 answers

How to color unit tests with lib minitest or Test:Unit?

I would like to have unit tests output color in my dev environment. However, I can't make it work on Linux (Debian and Ubuntu). When I include the following libs: require 'minitest/autorun' require 'minitest/unit' require 'minitest/pride' I…
poseid
  • 6,986
  • 10
  • 48
  • 78
15
votes
3 answers

In ruby, can you execute assert_equal and other asserts while in irb?

Can you execute assert_equal from within irb? This does not work. require 'test/unit' assert_equal(5,5)
Chris
  • 4,237
  • 6
  • 30
  • 42
14
votes
2 answers

Mocha: stubbing method with specific parameter but not for other parameters

I want to stub a method with Mocha only when a specific parameter value is given and call the original method when any other value is given. When I do it like this: MyClass.any_instance.stubs(:show?).with(:wanne_show).returns(true) I get an…
Sandro L
  • 1,140
  • 18
  • 32
13
votes
2 answers

How to get stack trace from a Test::Unit::TestCase

I am testing some Ruby code and have a failing Test::Unit::TestCase. Unfortunately, the failure report only gives me the top error, not a full stack trace. Specifically, it says: 1) Failure: test_tp_make(TestScripts::TestTpMake)…
Ryan Tate
  • 1,553
  • 2
  • 14
  • 21
13
votes
3 answers

How to output names of ruby unit tests

I have a unit test (example is modified Test::Unit documentation) require 'test/unit' class TC_MyTest < Test::Unit::TestCase def test_something assert(true) end end When I execute it, I get: Loaded suite C:/test Started . Finished in 0.0…
Željko Filipin
  • 56,372
  • 28
  • 94
  • 125
13
votes
1 answer

What is the difference between jest.mock(module) and jest.fn()

I have tried couple different ways of defining the mock function and all of my tries failed. When I try to define it as follow: jest.mock('../src/data/server', ()=> ({server: {report: jest.fn()}})); expect(server.report.mock).toBeCalledWith(id,…
Birish
  • 5,514
  • 5
  • 32
  • 51
11
votes
3 answers

Why 'undefined method `assert_equal' ' is thrown even after requiring 'test/unit'

I opened irb & entered: require 'test/unit' but when I used the assert_equal method, I got following error: NoMethodError: undefined method 'assert_equal' for main:Object. Why is this happening even after requiring 'test/unit' ?
Alpha
  • 13,320
  • 27
  • 96
  • 163
10
votes
2 answers

Is it still possible to use test-unit in rails 4?

After upgrading from Rails 3.2 to Rails 4, my app works, but my tests, written with test-unit, are a disaster. Minitest is rumored to be "compatible" with test-unit. However, if I attempt to use the (now bundled) Minitest, there are a raft of…
David W
  • 324
  • 1
  • 13
9
votes
3 answers

Rails colour highlighting for the Test::Unit/rake command?

When running test/unit using the rake test command from the terminal within a rails 3 project directory, the test result output is not coloured. Hence, it cannot be interpreted at a glance. Is there a way of getting colourised output for the…
John Kane
  • 3,601
  • 5
  • 23
  • 18
9
votes
3 answers

How to skip certain tests with Test::Unit

In one of my projects I need to collaborate with several backend systems. Some of them somewhat lacks in documentation, and partly therefore I have some test code that interact with some test servers just to see everything works as expected.…
Daniel Abrahamsson
  • 1,945
  • 2
  • 15
  • 20
9
votes
5 answers

How do i get RSpec's shared examples like behavior in Ruby Test::Unit?

Is there a plugin/extension similar to shared_examples in RSpec for Test::Unit tests?
Sathish
  • 20,660
  • 24
  • 63
  • 71
8
votes
1 answer

How to define common setup and teardown logic for all tests in ruby's Test::Unit::TestCase?

Assume there are potentially expensive operations to be performed in setup or teardown that are same for all tests and whose results doesn't get messed with during test runs. It seems not right to me to have them run before/after every single…
raphinesse
  • 19,068
  • 6
  • 39
  • 48
8
votes
2 answers

ruby Test::Unit Command line options?

When running tests in Ruby's unit::test framework, is there a really easy way to specify, from the command-line, that only one test should be run (that is, specify the test class and test member variable)? If not, is there another framework that has…
Joe Soul-bringer
  • 3,294
  • 5
  • 31
  • 37
8
votes
1 answer

Vue.js test-utils How to mock getters from module

In my ContactForm component , I have 2 computed mapGetters computed: { ...mapGetters(["language"]), ...mapGetters("authentication", ["loading"]), the first one is defined in my stoe/getters.js export const language = state => { return…
user762579
8
votes
3 answers

Rails fixtures - defining a table name?

At the minute all my fixtures have the same name as the table that they are intended for, because of a recent issue with rails it doesn't seem possible to have a fixture beginning with the word 'test' Does anyone know of a way to have a different…
Andy Donovan
1
2
3
24 25