Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6232641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:09:06+00:00 2026-05-24T10:09:06+00:00

I’m writing some ruby (not Rails) and using test/unit with shoulda to write tests.

  • 0

I’m writing some ruby (not Rails) and using test/unit with shoulda to write tests.

Are there any gems that’ll allow me to implement traceability from my tests back to designs/requirements?

i.e.: I want to tag my tests with the name of the requirements they test, and then generate reports of requirements that aren’t tested or have failing tests, etc.

Hopefully that’s not too enterprisey for ruby.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:09:08+00:00Added an answer on May 24, 2026 at 10:09 am

    Update: This solution is available as a gem: http://rubygems.org/gems/test4requirements

    Are there any gems that’ll allow me to implement traceability from my
    tests back to designs/requirements?

    I don’t know any gem, but your need was inspiration for a little experiment, how it could be solved.

    • You have to define your Requirements with RequirementList.new(1,2,3,4)
    • This requirements can be assigned with requirements in a TestCase
    • each test can be assigned to a requirement with requirement
    • after the test results you get an overview which requirements are tested (successfull)

    And now the example:

    gem 'test-unit'
    require 'test/unit'
    
    ###########
    # This should be a gem
    ###########   
    
    class Test::Unit::TestCase
      def self.requirements(req)
        @@requirements = req
      end
      def requirement(req)
        raise RuntimeError, "No requirements defined for #{self}" unless defined? @@requirements
        caller.first =~ /:\d+:in `(.*)'/
        @@requirements.add_test(req, "#{self.class}##{$1}")
      end
      alias  :run_test_old :run_test
      def run_test
        run_test_old
        #this code is left if a problem occured.
        #in other words: if we reach this place, then the test was sucesfull
        if defined? @@requirements
          @@requirements.test_successfull("#{self.class}##{@method_name}")
        end
      end
    end
    
    class RequirementList
      def initialize( *reqs )
        @requirements = reqs
        @tests = {}
        @success = {}
    
        #Yes, we need two at_exit.
        #tests are done also at_exit.  With double at_exit, we are after that.
        #Maybe better to be added later.
        at_exit {
          at_exit do 
            self.overview
          end
        }
    
      end
      def add_test(key, loc)
        #fixme check duplicates
        @tests[key] = loc
      end
      def test_successfull(loc)
        #fixme check duplicates
        @success[loc] = true
      end
      def overview()
        puts "Requirements overiew"
        @requirements.each{|req|
          if @tests[req] #test defined
            if @success[@tests[req]]
              puts "Requirement #{req} was tested in #{@tests[req] }"
            else
              puts "Requirement #{req} was unsuccessfull tested in #{@tests[req] }"
            end
          else
            puts "Requirement #{req} was not tested"
          end
        }
      end
    end #RequirementList
    
    ###############
    ## Here the gem end. The test will come.
    ###############
    
    $req = RequirementList.new(1,2,3, 4)
    
    class MyTest < Test::Unit::TestCase
      #Following requirements exist, and must be tested sucessfull
      requirements $req
    
      def test_1()
        requirement(1)  #this test is testing requirement 1
        assert_equal(2,1+1)
      end
      def test_2()
        requirement(2)
        assert_equal(3,1+1)
      end
      def test_3()
        #no assignment to requirement 3
        pend 'pend'
      end
    end
    
    
    class MyTest_4 < Test::Unit::TestCase
      #Following requirements exist, and must be tested sucessfull
      requirements $req
    
      def test_4()
        requirement(4)  #this test is testing requirement 4
        assert_equal(2,1+1)
      end
    end
    

    the result:

    Loaded suite testing_traceability_solutions
    Started
    .FP.
    
      1) Failure:
    test_2(MyTest)
        [testing_traceability_solutions.rb:89:in `test_2'
         testing_traceability_solutions.rb:24:in `run_test']:
    <3> expected but was
    <2>.
    
      2) Pending: pend
    test_3(MyTest)
    testing_traceability_solutions.rb:92:in `test_3'
    testing_traceability_solutions.rb:24:in `run_test'
    
    Finished in 0.65625 seconds.
    
    4 tests, 3 assertions, 1 failures, 0 errors, 1 pendings, 0 omissions, 0 notifications
    50% passed
    Requirements overview:
    Requirement 1 was tested in MyTest#test_1
    Requirement 2 was unsuccessfull tested in MyTest#test_2
    Requirement 3 was not tested
    Requirement 4 was tested in MyTest_4#test_4
    

    If you think, this could be a solution for you, please give me a feedback. Then I will try to build a gem out of it.


    Code example for usage with shoulda

    #~ require 'test4requirements' ###does not exist/use code above
    require 'shoulda'
    #use another interface ##not implemented###
    #~ $req = Requirement.new_from_file('requirments.txt')
    
    class MyTest_shoulda < Test::Unit::TestCase
      #Following requirements exist, and must be tested sucessfull
      #~ requirements $req
    
      context 'req. of customer X' do
        #Add requirement as parameter of should
        # does not work yet
        should 'fullfill request 1', requirement: 1  do
          assert_equal(2,1+1)
        end
        #add requirement via requirement command
        #works already
        should 'fullfill request 1' do
          requirement(1)  #this test is testing requirement 1
          assert_equal(2,1+1)
        end
      end #context
    end    #MyTest_shoulda
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I need a function that will clean a strings' special characters. I do NOT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.