Skip to content

Instantly share code, notes, and snippets.

@Ironholds
Created December 16, 2014 16:58
Show Gist options
  • Save Ironholds/30c09e6b4402bfc0e967 to your computer and use it in GitHub Desktop.
Save Ironholds/30c09e6b4402bfc0e967 to your computer and use it in GitHub Desktop.
//Example: this is an existing test
public void testIsPageviewApp() {
Text uriHost = new Text("en.wikipedia.org");
Text uriPath = new Text("/w/api.php?action=mobileview&sections=0");
Text httpStatus = new Text("200");
Text contentType = new Text("application/json");
Text userAgent = new Text("WikipediaApp/1.2.3");
IsPageviewUDF udf = new IsPageviewUDF();
assertTrue(udf.evaluate(uriHost, uriPath, httpStatus, contentType, userAgent).get());
}
//The difficult-to-export bit here is Text foo = new Text("bar"); - that's the thing where lots of languages use very different
//structures.
//Can we just do...
assertTrue(udf.evaluate("en.wikipedia.org","/w/api.php?action=mobileview&sections=0","200","application/json","WikipediaApp/1.2.3");
//?
//If so, we could use this formatting to make the tests more exportable
//C++? replace "assertTrue" with "assert"
//R? replace "assertTrue" with "expect_true"
//Python? leave as is!
//The test is far more reusable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment