Overview "Testing smw-cindykate"

From SMW CindyKate - Main
Component1650400913
Jump to: navigation, search

Content

WorksWithResourcesInCategory Category:SMWCKTesting

Preparations

  1. Make sure testSMWidentifier = 'smwck_production' is accessible. Alternatively you can use a locally run clone testSMWidentifier = 'your_smwck_clone'.

Method Tests

Notice:

Add a new method test

  1. Add the method at ApplicationMethod.
  2. Set up unit tests testing the new method at DSKIMUnitTest. If appropriate, run tests against test pages in Category:TestCategory0 and Category:TestCategory1.
  3. Look up ComponentXXXXXXXXXX's Property:TestsAreRunBy.
user@workstation:~/smw-cindykate$

Run All Enabled Method Tests

TESTSMWID=smwck_production METHODS="" rspec --format documentation --color spec/smw-cindykate/smw-cindykate_methods_spec.rb

Aspect "Wikitexts Objectification and Stringification"

Check code base using egrep -nr "(objectify|stringify)_wikitext" lib/smw-cindykate.

Page Origin Methods

Application Method Documentation/Unit Tests

Page Selecting Methods

In case of Application Method "Dataspects::Facet.from_oSEMANTICMEDIAWIKI( oSemanticMediaWiki )", if SMWCindyKate::Pages.pages is empty, then SMWCindyKate::Pages.pages defaults to SMWCindyKate::Pages.from_NAMESPACES(:Main). This is defined in private method SMWCindyKate::Pages.if_necessary_get_default_pages.

Application Method Documentation/Unit Tests

Page Filtering Methods

Application Method Documentation/Unit Tests

Data Getting Methods

TESTSMWID=smwck_production rspec --format documentation --color spec/smw-cindykate/wikitext_data_getting_methods_spec.rb
Application Method Documentation/Unit Tests

Data Setting Methods

Application Method Documentation/Unit Tests

Page Storing Methods

TESTSMWID=smwck_production rspec --format documentation --color spec/smw-cindykate/page_storing_methods_spec.rb
Application Method Documentation/Unit Tests

Change Verifying Methods

Application Method Documentation/Unit Tests

Other RSpecTags

clear; egrep -nr --include \*.rb " *, *:[_a-zA-Z0-9']+ *=> * (true|false) * do *" /media/lex/LEXUSB160424/Software/smw-cindykate/spec/

Run :alltests

rspec --pattern spec/\*\*/\*_spec.rb --format documentation --color --tag 'alltests'
clear; egrep -nr --include \*.rb " *, *:alltests *=> * (true|false).* do *" /media/lex/LEXUSB160424/Software/smw-cindykate/spec/

Understanding

Testing resources ($unit_test_pages and $pool_test_pages) are loaded from a SMW whose identifier is specified in spec/spec_helper.

For testing wikitext management, unit tests under spec/smw-cindykate are loading PoolPages→Command→ExpectedPages constellations (e.g. Unit Test "Application Method "SMWCindyKate::Pages.having_FIELD_NAME_in_TEMPLATE_NAME" for in multiple template calls of which some already have that field") from the SMW by ask queries for RSpec tags, e.g.

# spec/smw-cindykate/pages_selectors_spec.rb
run_unit_tests_for_rspec_tag("having_FIELD_NAME_in_TEMPLATE_NAME", "Pages Selector")

Correspondingly, on this SMW, #ask:[[HasRSpecTag::having_FIELD_NAME_in_TEMPLATE_NAME]] returns: .

# spec/smw-cindykate/spec_helper.rb
def page_selector_test tag
  describe ".#{tag} (Page Selector Test)", tag.to_sym => true do
    $unit_test_pages.from_ASK_QUERIES("[[HasRSpecTag::#{tag}]]")
    $unit_test_pages.pages.each do |object_id, page|
      utp = UnitTestPage.new(page, __FILE__)
      it "#{utp.description}" do
        $pool_test_pages.send(*utp.pool_pages)
        $pool_test_pages.send(*utp.command)
        expect($pool_test_pages.page_names).to match_array(utp.expected_pages)
      end
    end
  end
end

def wikitext_mutator_test tag
  describe ".#{tag} (Wikitext Mutator Test)", tag.to_sym => true do
    $unit_test_pages.from_ASK_QUERIES("[[HasRSpecTag::#{tag}]]")
    $unit_test_pages.pages.each do |object_id, page|
      utp = UnitTestPage.new(page, __FILE__)
      it utp.description do
        wikitext = SMWCindyKate::SMWWikitext.new(utp.before)
        wikitext.send(*utp.command)
        expect(wikitext.reassembled_wikitext).to eq(utp.after)
      end
    end
  end
end

These unit tests would be run by executing rspec --pattern spec/\*\*/\*_spec.rb --format documentation --color --tag 'having_FIELD_NAME_in_TEMPLATE_NAME'.

The Command is then run against each of the $unit_test_pages.

Configuration

Category:SMWCKTesting

Notice:

The following pages serve as unit test scripts and corresponding test objects/pages requested from within the RSpec Ruby code by API calls to this MediaWiki. While this mechanism turns these pages into a comfortable documentation about smw-cindykate's functionality, it also makes testing prohibitively slow.

The idea is to compile these pages into a YAML package dumped into smw-cindykate's RSpec testing suite before running them.

Run with rspec --pattern spec/\*\*/\*_spec.rb --format documentation --color --tag '<RSpec Tag>'.

Unit Test Pertains to object Smw factory component logo rspec.png RSpec Tag Describes scenario


Category:SMWCKTesting

Category:TestCategory0
TestPage0
TestPage1
TestPage4
TestPage5
Category:TestCategory1
TestPage3
TestPage4
TestPage5