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 3601842
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:40:17+00:00 2026-05-18T20:40:17+00:00

I’m using standalone autotest in my projects along with minitest . In one of

  • 0

I’m using standalone autotest in my projects along with minitest. In one of my projects, I have a single file (validation.rb) that validates a document to different internal format levels. (A Level 2 document has more features than a Level 1 document.)

Testing the validation for a particular level requires repeatedly loading in a known-valid document, subtly mutating it in broken way, and then ensuring that it is broken. In short:

class TestValidation < MiniTest::Unit::TestCase
  def setup
    @l1 = Document.load( L1DOC )
  end
  def test_valid
    assert @l1.valid_level_1?
  end
  def test_unbalanced_data
    @l1.instance_eval{ @tracks[0].data.pop }
    refute @l1.valid_level_1?, "Validation must ensure that all tracks have the same amount of data"
  end
  # many more tests for level 1 here
end

The problem is that autotest (as far as I can tell) knows which tests to run based on the name of the test classes. TestValidation will have its tests automatically run when validation.rb is changed.

Without autotest, I would have named the above class TestL1Validation, and created a new class TestL2Validation that loaded a different document. Doing this breaks autotest, however, unless I break out my validation into l1validation.rb and l2validation.rb.

How can I name my files or tests, or set up my tests, so that autotest will run multiple test classes when a single source file changes?

  • 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-18T20:40:18+00:00Added an answer on May 18, 2026 at 8:40 pm

    You can add custom mappings for autotest. Here’s one way of doing it:
    Create autotest directory at the same level as lib and test directories.

    Add autotest/discover.rb:

    $LOAD_PATH.unshift File.expand_path('../', File.dirname(__FILE__))
    Autotest.add_discovery { "my_rules" }
    

    Add autotest/my_rules.rb:

    require 'autotest'
    
    class Autotest::My_rules < Autotest
      def initialize
        super
    
        add_mapping(%r%^lib/valid.rb$%, true) { |filename, _|
          files_matching %r%^test/test_.*\.rb$%
        }
      end
    end
    

    This will add a custom mapping: whenever lib/valid.rb files has changed, re-run all test_*.rb files in test directory.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

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
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
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 have thousands of HTML files to process using Groovy/Java and I need to
I have a reasonable size flat file database of text documents mostly saved in
I am using parse_ini_file to read the contents of a file however it is

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.