Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sripathikrishnan/noregress
Regression Test Library to Assert Web Performance
https://github.com/sripathikrishnan/noregress
Last synced: 2 months ago
JSON representation
Regression Test Library to Assert Web Performance
- Host: GitHub
- URL: https://github.com/sripathikrishnan/noregress
- Owner: sripathikrishnan
- License: mit
- Created: 2011-08-21T05:48:15.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2011-10-13T16:01:39.000Z (about 13 years ago)
- Last Synced: 2023-07-28T17:43:36.967Z (over 1 year ago)
- Language: Java
- Homepage:
- Size: 395 KB
- Stars: 7
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.textile
- License: LICENSE.txt
Awesome Lists containing this project
README
h1. Regression Test Library to Assert Web Performance
Noregress lets you write junit tests to verify your websites performance does not degrade over time.
Noregress uses "Google PageSpeed Online API":http://code.google.com/apis/pagespeedonline/v1/reference.html. You will need to register with Google and obtain a (free) API key.
h2. Using Noregress
h3. Step 1 : Get a Free API key from Google
* Visit "Google's API Console":https://code.google.com/apis/console. In the Services pane, activate Page Speed Online API; if the Terms of Service appear, read and accept them
* Next, go to the "API Access pane":https://code.google.com/apis/console#access. The API key is near the bottom of that pane, in the section titled "Simple API Access."Consult "Google's API Console Help":http://code.google.com/apis/console-help/#WhatIsKey if you need more information.
h3. Step 2 : Download Noregress Library
For maven users :
org.noregress
noregress
0.2.0
testIf you don't use maven, "download the jar from sonatype repository":https://oss.sonatype.org/content/repositories/releases/org/noregress/noregress/. Noregress-x.y.z.jar is self-contained and does not have any external dependencies.
h3. Step 3 : Writing Test Cases
See "GithubPerformanceTest":https://github.com/sripathikrishnan/noregress/blob/master/src/test/java/org/noregress/GithubPerformanceTest.java for a complete example. An excerpt is shown below.
@Test
public void testGithubHomePageInAnonymousMode() {
PageTester tester = new PageSpeedOnlineV1Service("");
Result result = tester.testPage(new Request("http://github.com/"));
/*
* Basic Assertions
*/
assertEquals("Http Response Code", 200, result.getResponseCode());
assertEquals("404's on page", 0, result.getBadRequests().size());
assertTrue("Too many domains used on the page", result.getNumberHosts() < 6);
/*
* If somebody adds a new image or a new css/js file, these tests will catch them
*/
assertTrue("Too many resources on page", result.getNumberResources() < 35);
assertTrue("Too many JS resources on page", result.getNumberJsResources() < 5);
assertTrue("Too many CSS resources on page", result.getNumberCssResources() < 2);
/*
* Github doesn't compress SVG files, when they should.
* But just to demonstrate the flexibility of Noregress,
* we will ignore svg files as part of this test
*/
List resourcesWithoutGzip = result.getResourcesWithoutCompression();
List filteredResources = ignoreURIPatterns(resourcesWithoutGzip, "^.*svg$");
assertTrue("GZip not enabled on some ", filteredResources.isEmpty());/*
* Several other assertions are possible.
* Look at org.noregress.Result and org.noregress.pagespeed.PageSpeedResult
*/
}h2. How does Noregress work?
# Noregress makes a call to Google Page Speed Online API with the URL of your website
# Google's servers make a request to your website, analyse the performance and return a JSON result
# Noregress parses the result and provides a convenient API to assert there are no regressionsNoregress can be made to work against WebPageTest.org 's REST API. That's a TODO. See Issue #1
h2. Best Practices
# Use Noregress as part of your integration tests. Its a great idea to run these tests along with your Selenium tests
# Make lots of small "actionable assertions", instead of one big assertion. For example, asserting the overall page score will catch all regressions, but you won't know what change caused that regression. Instead, checking for something like "Number of JS resources on a page" will tell you exactly what broke the test and how to fix it.
# You have a limit of 250 requests a day. Assuming you do 10 commits per day, you can test 25 pages on your website. Choose wisely!h2. Anything else I should know?
# This library wraps Google's API, so you should read and comply with their terms and conditions
# You can only test 250 pages per day. This limit is set by Google's Page Speed API
# The pages need to be accessible over public internet. You cannot use this library behind the firewall
# You cannot use this library for password protected pagesh2. License
Noregress is licensed under the MIT License
The MIT License
Copyright (c) 2011 Sripathi Krishnan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.h2. Author
Sripathi Krishnan
Email : <FirstName><dot><LastName> at gmail.com