Inventory Developer Test Plan
Overview
This document describes the plan for testing the inventory application. Originally these tests were done manually, however the tests are now done automatically with Selenium tests
Automated Testing
The topics discussed below the automated testing are old manual tests that these automated tests are based on. These automated tests cover the manual tests, as such you only need to run the automated tests. They take about 6 minutes to run all of the tests. I will instruct you how you can setup and run the automated tests. The automated tests should be run at least once before releasing a new version.
Requirements
- Java installed
- Firefox installed
- PHPUnit (explained below)
- Selenium Server (already in git, explained below)
Installing/Setup/Running
To install you simply need to run the file named "unitTest". You will want to run it like this:
./unitTest install /location/to/.htpasswd
Note: If you already have phpunit installed, please remove the phpunit file from /usr/local/bin/ before running the installer. The installer will add a legacy version of phpunit (4.7.1) so there are no compatability issues when running the Selenium tests.
This will install everything that needs to be installed. It will install the selenium-server.jar, phpunit, add a testing user to your htpasswd file, and create a screenshots directory in test/screenshots as selenium will save screenshots so you can see where errors happened. It is safe to run the install function in the future as the script will only install, or add a new htpasswd entry if it does not exist. The script may prompt you to enter a password as sudo is required to run one of the commands.
At the end of the install you'll be asked to run an SQL query on your inventory database, please do this otherwise there will be errors when the tests run. This is simply adding the testing user to the database. The SQL query is given via the commandline, just copy and paste this into phpmyadmin or the mysql console.
To now run the unit testing you should do the following:
./unitTest run cs
This will run the CS version of the tests.
./unitTest run mfcf
This will run the MFCF version of the tests.
./unitTest run all
This will run both CS and MFCF versions of the tests.
Please note: Firefox windows will pop up, this is normal! You can try to continue your work, however these windows will keep popping up so it is better if you don't try to. The tests will take about 6 minutes to run. If all of the tests fail and all of the errors look something like "CURL error while accessing the Selenium Server at..." then I suggest rerunning "./unitTest run" as sometimes the selenium server is slow to startup which means all of the selenium tests will not work. Running it again usually resolves the issue.
Note: If you get a php error about failing to open a stream relating to PHPunit files right at the top of the execution you can likely ignore these warnings.
Adding New Test Cases
When adding new test cases, there are a few conventions you must follow in order for PHPUnit/Selenium to recognize your new functions/tests.
When naming the PHP file that contains your tests, they must end in 'Test.php' otherwise PHPUnit will not run them. The files can be named anything you please, as long as the ending is correct.
Example: MyUsefulTest.php, InventorySearchTest.php
Inside of your newly created *Test.php file, you must create a class with the same name as the file. If my file is named 'MyUsefulTest.php', my class will be called 'MyUsefulTest'. Your class must also extend 'WebTestCase'.
Example:
<?php
class MyUsefulTest extends WebTestCase {
//Testing functions go here
}
?>
When writing your testing functions there is also a naming convention required for the tests to be executed by PHPUnit. Each test function must start with 'test'.
Example:
public function testVeryUsefulTest() {
}
You can also write helper functions within your class, however you will want to omit the 'test' at the beginning of the function name otherwise PHPUnit will try to run it as a test.
Example:
//PHPUnit won't try to run this, but you can access it from your test functions.
public function myHelperFunction() {
}
//PHPUnit will run this function, and you can use your helper functions within this.
public function testVeryUsefulTest() {
$this->myHelperFunction();
}
Note: The test functions are run from top to bottom within your class, and the classes (files inside functional/) are run in numerical order.
Testing Process
The tester will sequentially go through the steps listed below and ensure the results are as described. Any differences are either a bug to fix, or a change that must be made to the test plan.
Test Cases
Home/Search Page
- Start from a new private session (before logging in to CAS); and visit the application's main page - http://cs.uwaterloo.ca/cscf/internal/inventory/
. Log in to CAS. On authenticating, the tester will see the Search Page (rather than an error page).
- The Version Number at the bottom will be the new version, not "Dev Version".
- "Home" button will re-load the same page.
- "More Options" will load the "More Options" page (see below).
- "New Record" will load the New Record page (see below).
Search Criteria
Search Every Item Bar
- The Search All bar is located at the top of every page.
- (TEST FUNCTIONALITY AND REDIRECT) Search for the barcode of a known item like "CS008198" with the scope "Current" and "Active". This should bring up the update page for that item.
- (TEST ERROR DISPLAY) Repeat #2, but change the scope to "Inactive"; this should cause an error to display and return no results.
- (TEST HISTORY AND CURRENT SCOPE) Follow the steps below:
- Search for "CSCF" with scopes "Current" and "Active and Inactive", then note the number.
- Repeat (1), instead using the scope "History", note the number.
- Repeat (1), instead using scope "Current and History", note the number.
- Correct functionality is indicated if the number of results is roughly: (3) > (1) > (2) 2 may be greater than one, but definitely 3 will be bigger than 1 and 3 will be bigger than 2.
- (TEST ACTIVE SCOPE) Follow the steps:
- Search for "CS" with the scope "Current" and "Active". Click on the "active" table header twice to determine if any of the results have an "n" written in--none should.
- Repeat (1), but with "Inactive" and checking for a "y" in the active column. There should be no "y" value present.
- Repeat (1), but with the scope "Active and Inactive" and make sure that both "y" and "n" are present.
- (TEST SEARCH MATCH OPTION) Repeat #2, but change the search term to "S008198" and use the option "ends with". Go through the list and try the different options and variations of the string "CS008198" to ensure functionality is as expected.
Search Short/Long Bar
- These tests can be conducted on the small search block displayed by clicking on "home" (also displayed when first opening the app), and the long search block displayed by clicking on "advanced" button (after clicking on home).
- (TEST CRITERIA FILTER AND ERROR DISPLAY) Follow these steps:
- Write a known barcode into the barcode search with scope "Current" and "Active and Inactive". This should result in redirection to the item's update page.
- Write the barcode in a different input box. This should result in a failed search and should display an error.
- (TEST HISTORY AND CURRENT SCOPE) Follow the steps given in #4 in the previous section "Search Every Item Bar", but use the field, "equipment type" and the term "computer".
- (TEST ACTIVE SCOPE) Follow the steps given in #5 in the previous section "Search Every Item Bar", but use the field "equipment type" and the term "computer".
- (TEST SEARCH MATCH OPTION) Follow the steps given in #6 in the previous section "Search Every Item Bar", but use the field "barcode".
More Options Page
- The room options item will redirect to the room options page (see below).
- The mass add item will redirect to the mass add tab on the mass operations page (see below).
- The mass update item will redirect to the mass update tab on the mass operations page (see below).
- The evergreen item will redirect to the evergreen page (see below).
-
The barcode loaning item will redirect to the barcode loaning page (see below).
Room Options
- (TEST ROOM CHANGE) Follow the steps:
- Type in the room "dc2608" and click on the machines page--note the machines present.
- Type in the room "dc2610" and click on the machines page; compare this to the previous results for machines present. They should be different.
- (TEST BARCODE ROOM CHANGE) Follow the steps:
- Type in the room "dc2610" and click change room.
- With the barcode ops tab open, in the input box, type in the number of a known barcode of a machine that was not in the machine list of that room previously, i.e. "cs008198".
- Switch to the machine tab and check that the item is not present in the room.
Mass Add Tab
- (UPDATE DNS) For every test, ensure update dns is not clicked, this requires the IPAM executable to be installed and at this time is not being tested.
- (TEST CSV CRITERIA REQUIREMENTS) Follow these steps:
- Paste this csv text into the text box to create a new item (copy everything between the quotes and paste into text box):
"pKey
1234567890"
2. Run the mass add with the text. An error should display with text similar to the following: "equipmentType is required for mass adds, room is required for mass adds, model is required for mass adds, sponsorCode is required for mass adds".
3. Copy, paste and run the following csv text:
"accountNumber,active,authUser,barcode,comments,contractAFF,contractBegins,contractCost,contractEnds,contractPurchaseOrder,contractQuoteNumber,contractVendor,cpuModel,description,domain,dns_admin,dns_contact,edocsUrl,equipmentType,fixedAssetTag,found,groups,hardware,hostDomainName,ipAddress,macAddress,memory,model,numberOfCPUs,operatingSystem,operatingSystemSNMP,policyEight,processor,purchaseCost,purchaseOrder,purpose,quotaFile,region,room,serialNumber,special,speed,sponsorCode,subscriptionCode,supportAFF,supportBegins,supportClass,supportEnds,vendor,warrantyStart,warrantyStop
2951-800-100-0669-000000-6206-0216-000,y,,CS009376,"ST#93170, ST#99093",,,,,,,,,Black ASUS LED Display 27” wideIPS monitor,uwaterloo.ca,,,,Display,,,,,,,,,PB278Q,,,,Restricted,,650,199671,MC3004 Undergrad Lab Monitor,,,DC2560,E2LMTF058431,,,CS030,,,,Retired,,Telecom Computers,4/11/2014,4/10/2017"
4. The result should be successful.
3. (TEST BARCODE DUPLICATION AND ITEM CREATION) Follow these steps:
- Repeat #2(3). This should be permitted since barcodes are allowed to be shared between multiple items.
- Search for the barcode "CS009376". The number of results that appear should correspond to how many times #2(3) was run.
4.
(TEST CSV VALIDATION) Repeat #3(4), but remove a comma in the bottom most line. An error should display citing too many or too few columns as the reason.
Mass Update Tab
- (UPDATE DNS) For every test, ensure update dns is not clicked, this requires the IPAM executable to be installed and at this time is not being tested.
- (TEST UPDATING AN ITEM) Follow these steps:
- Search up the pKey 15349 and note its equipment type.
- Copy, paste and run the following csv text (everything inside the quotes):
"
pKey,equipmentType
15349,Terminal"
3. Search the item up after the previous csv has been input and run, the equipment type should now say "Terminal".
3. (TEST MASS UPDATE BARCODE) Follow these steps:
-
- Follow the steps from the previous section "Mass Add Tab" #3 to create multiple items with the same barcode.
- Copy, paste and run the following csv text:
"barcode,equipmentType
CS009376,Terminal"
3. The edit should be successful and it should display a number of lines indicating a successful edit. The number of lines that appear directly relates to the number of items that were successfully edited.
4. (TEST CSV ERROR) Copy the csv from #3(2), except replace the barcode with "asdfwejo". Nothing should happen because no item matches this barcode. (this should be changed in the future to be more descriptive)
5. (TEST CSV VALIDATION) Copy the csv from #3(2), except remove ",Terminal" from the bottom row and submit. This should cause an error which cites number of columns as the reason.
Evergreen
Barcode Loaning
New Record Page
- On page load the following dropdown menus should be present: "General, DNS, Support, Hardware, Maintenance". (For the CS Version, Math doesn't have DNS)
- (TEST DYNAMIC MENU DISPLAY) Switch the equipment type from "Computer" to "Projector" should cause the drop down menus "DNS" and "Hardware" to disappear.
- (TEST FIELD VALIDATION) Follow these steps:
- Change the equipment type to "Please Select" (the default option at the top) and click create. An error message should pop up preventing the creation.
- Change the equipment type to "Computer" and ensure the policyEight option says "Please Select" (the top value), click create and an error should pop up regarding the policy eight setting.
Update Item Page
- (TEST IF PROPER ENVIRONMENT IS SET) Change the equipment type to "computer". If using the cs version of inventory, the menu "dns" should be present; if using the math version of inventory, then dns should not appear.
- (TEST BUTTONS AND MENUS) Follow these steps:
- Click on "Expand All". A loading icon should display indicating ajax requests are being processed. After loading all menus should open.
- Click on "Collapse All". All menus should collapse.
- Reload the page and click on each menu individually to ensure the menus load.
- Open the dns menu (if the menu is not present then ensure the cs version of inventory is being used and change equipmentType to computer). Then click on the dropdown list next to the label "Find A Free IP In A Range". This should cause the ajax loading icon to display momentarily and the list should populate.
- Open the "Support" menu and click on the "Sponsor Code" drop down. This should load and populate.
- Open the "History" menu and check that everything looks alright.
- Open the "Licences" menu and click on the sponsor drop down. It should populate and display as well.
- (TEST ERROR HANDLING FOR DEFAULT MENUS) Change the equipment type to the top option, "Please Select", and try saving the item. An error should be thrown and nothing should be saved.
- (TEST ERROR HANDLING FOR DROP DOWN MENUS) Open the Support menu and input "asdf" into the textfield for "Support AFF". After submitting an error should be displayed and the menu should be opened automatically with the field highlighted and an additional error message under the input box. Also note that if a valid change in the input of the default menus--one that doesn't cause an error--then part of the item will be saved. This is expected.
- (TEST DYNAMIC MENU DISPLAY) Switch the equipment type from "Computer" to "Projector" should cause the drop down menus "DNS" (if using 'cs' inventory) and "Hardware" to disappear.
- (TEST FIND A FREE IP IN A RANGE FEATURE) Follow these steps:
- Open the dns menu (must be cs inventory on an item that is not a printer, display, or other).
- Click on the drop down next to the label "Find A Free IP In A Range". The AJAX loading symbol should pop up for about 2-3 seconds, then the menu should display in monotype print for easy viewing.
- Click on an item with no free ip addresses in its range. An error box should pop up explaining that no ip addresses are available.
- Click on an item where the hostname (far left column) is in the range (172.19.1.60 - 172.19.1.240) where there are no used slots--it should say "2/2 free". Two things should happen: 1. The ip address input box in the "General" menu should now read a new address. 2. the address automatically choosen should not be the same as the hostname ipaddress; this is because routepoint's and broadcast points are restricted ip addresses.
- Save the new address selected from (4). Reload the page and reopen the "Find A Free IP In A Range" dropdown menu; scroll down to the hostname that was selected and check to see that the number of available ip addresses in the range has decreased by 1.
- (TEST GENERATE CSV) Click on the "Generate CSV" button at the top right. The AJAX loading icon should pop briefly and then a dialog box with the item's CSV should appear. Copy this CSV and paste it into the Mass Add page to make sure the CSV is valid--this will likely cause some errors for duplicate entries such as duplicate ips, but the important thing is that there is no error for badly formatted CSV (i.e. number of columns). Also try downloading the CSV to ensure the link works.
- (TEST DUPLICATE RECORD) Click on the "Duplicate Record" button at the top right of the page. This should bring up a create new item page with an error/warning dialog indicating the unique values have been removed. The other input boxes should be filled in appropriately; i.e. check in the menu "Hardware" and see if the MAC address was copied--it should have been.
- (TEST CHECKOUT FEATURE) Follow these steps:
- Click on the "Check Out" button at the top right of the page. This should change the page to the check out page.
- Input a random name and comment and click "check out".
- Go back to the item's page and there should be a red line of text at the bottom of the "General" menu indicating that the item is currently checked out.
- Open the "Loan History" menu at the bottom to see that the item has been checked out.
- Click on the button "Check In" located at the top right of the screen. This should redirect to the check in page.
- Click check in and some text should appear indicating that the item has been checked in. Click on "Check In" a second time and test to see if an error pops up indicating the item is not currently on loan.
- Go back to the item's page and see if the red text at the bottom of the "General" menu is gone.
- Open up the "Loan history" menu and check to see if the check in was added to the history.
- (TEST DELETE FEATURE) Follow these steps:
- Open an item in the inventory app (make absolutely sure this is connected to a testing database).
- Click delete on the item--a dialog box should pop up to confirm the operation.
- Click yes--this should redirect to the home page with a notice showing that the item was deleted.
- Try reloading the item by searching it up--no results should be displayed.
- (TEST ATTACHMENTS) Follow these steps:
- Open an item in the inventory app.
- Open the attachments drop down menu.
- Click the "Choose File" button.
- Select a file to upload.
- Save the item.
- Open the attachments drop down menu again--the file that was uploaded should appear in the table.
- Click on the file link--this should redirect to the file and allow downloading of it.
-- DanielAllen - 2015-04-01