If I had a dollar for each time I’ve used some kind of upload system, I’d be a rich man.
There are plenty of online systems where you would want to attach or transfer a file.
In this article, I will give you a list of positive and negative test cases for file upload functionality.
To further help you, I’ll provide an example of some business/functional requirements.
Read on.
Table of Contents
Context and Scope
For the context of this article, we will use the example of the WordPress image upload feature as it captures the most popular features.
The uploading process is essentially the same for most systems so you can use the examples in this article and implement them elsewhere.
First things First – IT Security
Before I begin talking about the test cases, uploading files can be an IT security nightmare.
There are always potential security risks such as a SQL injection or other loopholes in security..
Anyone accessing your systems externally can always present a risk.
On projects such as these, you may have to work very closely with your IT Security, IT Engineering and Support teams.
Requirements to Consider
The quality of Your Testing will only be as good as the requirements you have.
Below are somes standard features that I’d expect to see as part of any application that incorporates file upload functionality.
This is not an exhaustive list and only provided as an example.
You should speak to your Organisation’s Business Analyst or Subject Matter Expert (SME) to obtain a full set of business, functional and non-functional requirements.
Requirement ID | Functionality Area | Requirement Description |
FU-REQ-001 | File name | The file name must adhere to the following convention(s); Condition 1 Be a minimum length of 1 Condition 2 Be a maximum length of 255 characters Condition 3 Not contain any special characters Condition 4 Contain a single full stop/period to separate the file name and file extension. Check out more details on filenaming conventions. |
FU-REQ-002 | File Type | The application will only accept the following image file types; .jpg .jpeg .png .gif .webp An example of accepted file types can be seen here at the WordPress site. |
FU-REQ-003 | File Type | The application will only accept the following document file types; .doc .odt .xls .key .ppt |
FU-REQ-004 | File Type | The application will only accept the following audio file types; .mp3 .m4a .ogg .wav |
FU-REQ-005 | File Type | The application will only accept the following video file types; .mp4 .mov .avi .mpg |
FU-REQ-006 | File Path (Location) | Each file will be uploaded in it’s corresponding folder. URL / year / month / day / For example; Images uploaded on the 1st December 2021 will be uploaded to its corresponding folder. website.com/2021/12/01 |
FU-REQ-007 | File Extension | Acceptable file extensions for images, document, audio and video will only be accepted. The system will reject any file extension that is not in the acceptable list. |
FU-REQ-008 | Maximum File Size | Each file must not exceed a maximum file size of 48mb. |
FU-REQ-009 | Multiple File Upload | The system must have the ability to upload multiple files. |
FU-REQ-010 | Buttons and Controls | The application should display and Upload Button that allows a user when clicked to; Upload a valid fileReject an invalid filePrompt a user to take an action if there is no file attached |
Before You Start Writing Your Test Cases
If you are new to writing test cases, then please read our detailed guide on how to.
Below are some ideas for your Test Plan.
Enjoy.
Positive Test Cases for File Upload Functionality
For positive tests, you’ll be validating the ‘happy path’ upload process in your web application.
In some instances, it’s better to test a specific test condition and keep everything else the same.
Test Case ID | Test Case Description | Expected Result |
TC-FU-001 | Validate User Interface (UI) of the file upload screen is being rendered correctly. | The screen should be displayed as expected from the UI Specification. |
TC-FU-002 | Ensure File name meets minimum length | System will accept file upload. |
TC-FU-003 | Ensure File name does not exceed maximum length | System will accept file upload. |
TC-FU-004 | Ensure File name does not contain special characters | No special characters will be displayed. System will accept file upload. |
TC-FU-005 | Ensure image upload is a valid File Type. Note: Please refer to requirement ID FU-REQ-002 for more details on accepted file formats. | System will accept image file upload. Confirmation is displayed. |
TC-FU-006 | Ensure document upload is a valid File Type. For example, a word or excel file can be used. Note: Please refer to requirement ID FU-REQ-003 for more details on accepted file formats. | System will accept document test file upload. Confirmation is displayed. |
TC-FU-007 | Ensure audio upload is a valid File Type. Note: Please refer to requirement ID FU-REQ-004 for more details on accepted file formats. | System will accept document test file upload. Confirmation is displayed. |
TC-FU-008 | Ensure video upload is a valid File Type. Note: Please refer to requirement ID FU-REQ-005 for more details on accepted file formats. | System will accept document test file upload. Confirmation is displayed. |
TC-FU-009 | Ensure uploaded is valid File Path (Location) | System will accept document test file upload. Confirmation of upload is displayed. |
TC-FU-010 | Ensure uploaded file is a valid File Extension | |
TC-FU-011 | Validate file upload does not exceed Maximum File Size | |
TC-FU-012 | Verify that the system allows Multiple File Upload | |
TC-FU-013 | Validate end to end Upload Feature with a valid file. | The system accepts the file. The system processes the file. The system returns a confirmation message that the file has been uploaded successfully. |
To complete each test case as an end to end functional test, you need to verify that the file has uploaded successfully.
You should also capture test evidence at this point which will prove the test.
Positive test cases are great to test as part of any future ‘stand up’ tests.
Negative Test Cases for File Upload Functionality
The negative test cases are essentially the opposite of the positive test cases.
We are trying to ‘break’ the system by generating ‘exceptions’.
You should try and implement boundary value analysis as well as equivalence partitioning techniques here.
You’re most likely to find the large portion of defects during negative test cases so try and be a bit creative.
Sometimes the silliest of things can break a system.
Test Case ID | Test Case Description | Expected Result |
TC-FU-014 | Enter a File name less than the minimum length | File will be rejected Meaningful Error message will be displayed. |
TC-FU-015 | Enter File name that exceeds maximum length | File will be rejected Meaningful Error message will be displayed. |
TC-FU-016 | Ensure File name does contain special characters | File will be rejected Meaningful Error message will be displayed. |
TC-FU-017 | Ensure image upload is an invalid File Type. | File will be rejected Meaningful Error message will be displayed. |
TC-FU-018 | Ensure document upload is an invalid File Type. | File will be rejected Meaningful Error message will be displayed. |
TC-FU-019 | Ensure audio upload is an invalid File Type. | File will be rejected Meaningful Error message will be displayed. |
TC-FU-020 | Ensure video upload is an invalid File Type. | File will be rejected Meaningful Error message will be displayed. |
TC-FU-021 | Ensure uploaded is an invalid File Path (Location) | File will be rejected Meaningful Error message will be displayed. |
TC-FU-022 | Ensure uploaded file is an invalid File Extension | File will be rejected Meaningful Error message will be displayed. |
TC-FU-023 | Validate file upload does exceed Maximum File Size. | File will be rejected Meaningful Error message will be displayed. |
Another one for the Regression Suite
One thing that gives me a buzz each time I complete a set of test cases for a project is the fact that I can re-use them again.
If you have a regression test pack, you can literally add them there ready for the next time they need to be run.
Don’t Forget the RTM
As always, don’t forget to include your project requirements into a Requirements Traceability Matrix for test coverage.
Summary and Wrap up
Hopefully that gives you an insight into how to test file upload functionality.
You might also be interested in looking at creating test cases for a registration page.
You can go much deeper but I didn’t want to overcomplicate the article.
There are also drag and drop features you can test which I also didn’t cover here.
Feel free to reach out to me if you have any questions or comments.