• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Hands on training on DbFit Part-II
 

Hands on training on DbFit Part-II

on

  • 1,908 views

 

Statistics

Views

Total Views
1,908
Views on SlideShare
1,908
Embed Views
0

Actions

Likes
3
Downloads
39
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Hands on training on DbFit Part-II Hands on training on DbFit Part-II Presentation Transcript

    • Database Unit TestingwithDbFitPresented byMd. Babul MirdhaSenior Software EngineerLeads Corporation LtdPart-II
    • Working mode of DbFit Fixtures• DbFit fixtures can work in two modes:– Flow Mode– Standalone Mode
    • Flow mode:– a DatabaseTest fixture controls the whole pageand coordinates testing.– automatically rolls back the current transaction atthe end to make tests repeatable,– provides some additional options such asInspections of stored procedure error results.
    • Standalone:– In this case, we are responsible for transactionmanagement.– This enables you to have more control over thedatabase testing process
    • Connecting in flow mode• For Standard Connection:– Use the Connect method to initialise the databaseconnection.– Pass the server (optionally followed by the instancename), username, password and the database nameas arguments.!|dbfit.SqlServerTest|!|Connect|LAPTOPSQLEXPRESS|FitNesseUser|Password|TestDB|– If you are connecting to a default database, you can omit the fourth parameter.
    • Connecting in flow mode• For Non-Standard Connection:– use non-standard connection properties, or initialize your connectiondifferently (for example, using Windows integrated authentication),call Connect with a single argument — the full .NET connection string.!|dbfit.SqlServerTest|!|Connect|data source=Instance;userid=User;password=Pwd;database=TestDB;|– For flow mode to work correctly, the SqlServerTest fixture must be thefirst one on the page — not even import can be before it.– This is why we explicitly specify the namespace.
    • Transaction management- In flow mode• The current transaction is automatically rolled back at the end of the page.• If we want to commit it to make changes permanent, put the Committable into the page.• There are no arguments or additional parameters — the table contentscontain just this one word.• Likewise, you can roll back manually in your test using the Rollback table.!|dbfit.SqlServerTest|!|Connect|LAPTOPSQLEXPRESS|FitNesseUser|Password|TestDB|………|Commit|Or|Rollback|
    • Connecting in standalone mode|import||dbfit.fixture|!|DatabaseEnvironment|sqlserver||Connect|LAPTOPSQLEXPRESS|FitNesseUser|Password|TestDB|• Notice that there is no space betweenDatabaseEnvironment and Connect — they have to bein the same table.• Because we are not using flow mode, we can use theimport fixture as well.• Most DbFit fixtures are in dbfit.fixture namespace, so itis good practice to include this namespace.
    • Transaction management-In standalone mode• Use the DatabaseEnvironment fixture again, but do not specify a fixture argument.• This tells the DatabaseEnvironment to use the current default database connection, withoutattempting to initialise it.• Call Commit or Rollback in the second row.|import||dbfit.fixture|!|DatabaseEnvironment|sqlserver||Connect|LAPTOPSQLEXPRESS|FitNesseUser|Password|TestDB|………!|DatabaseEnvironment||Commit|Or!|DatabaseEnvironment||rollback|• It is a very good idea to put this table in a TearDown page for your test suite when you usestandalone DbFit fixtures.• This will make sure that your tests are repeatable.
    • DemoFlow Mode&Stand Alone Mode
    • More AboutWiki
    • Wiki ActionsAction Name Command To UrlEdit this page url?editCreate a new page directlycurrent-url.NewPageNameorcurrent-url.NewPageName?editTest this page url?testSuite test this page url?suiteSet properties of this page url?propertiesSee versions of this page url?versionsRefactor this page url?refactorSearch pages from here url?searchFormWhere is this page referenced? url?whereUsedDebug this test page url?debugSuite test this page with a suite filter"passing"url?responder=suite&suiteFilter=passing
    • Includes & InformationalTimestamp !lastmodifiedTimestamp !todayHelp text !helpContents List !contentsContents Tree !contents -RContents Sub-tree !contents -R[nn]Contents List - Graceful !contents -gContents List - Properties !contents -pContents List - Suite Filters !contents -fContents List - Help Text !contents -h
    • Include Page!include AnyPagePath expanded border!include -c AnyPagePath collapsed border!include -seamlessAnyPagePathno border!include -setup AnyPagePath appears like SetUp!include -teardownAnyPagePathappears like TearDown| !include AnyPagePath | in a table cell
    • Picture Insert!img url-to-image-file in-line!img-l url-to-image-file image left-justified, text wraps on right!img-r url-to-image-file image right-justified, text wraps on the left!img[-l |-r] url-to-image-fileas a clickable link
    • Fixture Symbol• Symbols are global variables that can be accessed using a simple syntax.• Symbols are stored in a static collection inside the Fixture class• To store a value of an output column into a symbol named player, write >>player into the cell.• To read a symbol value, and store it into an input column, use <<player.• Think of << and >> as arrows pointing the way.!|Insert|users||username|name|userid?||pera|Petar Detlic|>>peraid||Mika|Mitar Miric|>>mikaid|!3 Confirm that IDs are the same as in the database!|Ordered Query|Select * from users||username|name|userid||pera|Petar Detlic|<<peraid||Mika|Mitar Miric|<<mikaid|16
    • What is the scope of a symbol?• Symbols are stored in a static collection insidethe Fixture class.• so their scope is global from the point wherethey are defined until the test runner stops.• A symbol scope will effectively extend to allpages executed after the page where it isdefined.
    • Markup variableVariablesVariable Definition!define name {value}!define name (value)!define name [value]Variable Usage ${name}
    • What is the difference between variables and symbols?• Markup variables are processed by the wiki, before running tests.• Symbols are processed by the FIT engine while running tests.• Because of that, variables can be used even as a part of cell content.• you can use a markup variable:!define Markup {reader}|StringFixture||field|field?||acrobat ${Markup}|acrobat reader|• But this will not work:|Query | select ‘reader as Symbol|| Symbol?||>>MySymbol||StringFixture||field|field?||acrobat << MySymbol|acrobat reader|• Symbols are also available to fixtures at runtime, and variables are not.
    • Wiki and SubWiki Wiki: A normal Wiki is a collection of pages with a flat structure. All the pages are peers. You add a top-level page simply by placing a WikiWord on an existing top-level page,and then clicking on the ? SubWiki: FitNesse allows you to create Sub Wikis. Each Wiki page can be the parent of an entire new Wiki. You create a sub wiki page by ParentPage.SubPage (or the shortcut ^SubPage), and thenclicking on the ?… WikiparentSubWiki 1SubWiki 2http://fitnesse.org/FitNesse.UserGuide.SubWiki
    • Sub Wikis and Test suites• Each wiki (and sub wiki) can have its own– ClassPath– PageHeader, PageFooter– SetUp, TearDown– SuiteSetup, SuiteTearDown• Test Suites– A Test Suite executes all tests in the sub wiki (tree of pages)– SetUp and TearDown pages are invoked for each page of the suite– To wrap an entire suite, define the operations on pages SuiteSetUpand SuiteTearDown21
    • 22WikiSub-wikiRemember to initially create the first page
    • Demoon Wiki & SubWiki23
    • WikiImport• What is WikiImport?– allows you to import an entire wiki or subwikifrom another FitNesse site.– All of the pages from the remote wiki will becopied to your local FitNesse and become part ofyour local wiki.
    • • Why should I use WikiImport?– In a development environment it is most practical tohave a main FitNesse server where all the tests aremaintained and new tests are added.– However, it is not practical for all the developers torun the tests on one server.– Therefore each developer should have a FitNesseinstallation in their development environment.– The test pages from the main server get imported byeach developer so they can execute the most recenttests against their current code base.
    • How do I use WikiImport?– Create a page or use an existing page that willcontain the imported wiki.– Open the properties view of this page.– There is a form title Wiki Import.– Supply the URL to the remote wiki that youd liketo import– Submit the form.
    • Update imported wiki• Once a wiki has been imported, it may beupdated at any time.– Open the properties view of the importing page orany imported page.– There will be a button in the Import Wiki section.– Clicking this button initiate an update of all theimported pages beneath the currently selectedpage.
    • New Edit Buttons -WikiImport• Once you have imported a wiki, the Edit button will beturned off and two new edit buttons will be added:– Edit Locally and– Edit Remotely.• Edit Locally– behaves just like the Edit button that youve used all along.• Edit Remotely– allows you to easily edit the page from where the contentis being imported.
    • Automatic Update Option - WikiImport• Click on the page properties, youll see a checkbox that says:• Enabling this option will kick off an update forany test page prior to execution.• Child pages will inherit this option from parentpages, which means you need only set on theroot of you test hierarchy.
    • DEMOConfigure & Install & Local ServerImport wiki
    • Thank You!
    • Q & A