Did anybody used the unit-tests from the addon-sdk(cfx test)?
I made a test that looks like this:
exports.test_open_tab = function(test) {
const tabs = require("tabs");
tabs.open({
url: "http://valid url with lots of params",
onReady: function(tab) {
test.done();
}
});
test.waitUntilDone(600*1000);
};
basically this should open a tab, wait 600seconds, and them mark it as passed.
It actually displays a lot of errors and warning in the console from the loaded page(jquery and google analytics stuff, used by the loaded page) and then it marks the test as failed.
Any idea why?
One obvious issue is that you don't actually have any test results. If the fact that onReady() is called is a positive result you should write:
onReady: function(tab) {
test.pass("onReady called");
test.done();
}
Btw, the only case where it would wait 600 seconds is if onReady isn't called for some reason. Otherwise your test.done() call will complete the test execution.
You can somewhat reduce the number of warnings logged by disabling javascript.options.strict preference. However, these warnings might indicate real issues and in current Firefox versions it probably makes more sense to switch off display of JavaScript and CSS warnings in the console.
Related
I am using Firefox add-on HAR export trigger for test automation with Robotframework/Selenium. The test basically navigates to a web page and greps the exported har files for some expression. The test sometimes fails.
In those cases, I noticed that there are far less requests (about 20) in the har file than on the network tab of the browser window used by the test case (about 70). If I export those requests manually after the test case has stopped, all requests are exported as expected.
So I guess, something is interrupting the export function (although no other page is opened and the browser is not closed). I could use a dumb Sleep but is there a smarter way for the test client to check if exporting is still in progress? Some JS call maybe or a callback?
I tried to wait for a specific number of export files to exist, but that does not work reliably.
I've seen a parameter like devtools.netmonitor.har.jsonpCallback but don't how to use it. My settings are
("devtools.netmonitor.enabled", true);
("devtools.netmonitor.har.compress", false);
("devtools.netmonitor.har.defaultFileName", "Autoexport_%y%m%d_%H%M%S");
("devtools.netmonitor.har.defaultLogDir", <somepath>);
("devtools.netmonitor.har.enableAutoExportToFile", true);
("devtools.netmonitor.har.forceExport", true);
("devtools.netmonitor.har.includeResponseBodies", false);
("devtools.netmonitor.har.jsonp", false);
("devtools.netmonitor.har.jsonpCallback", false);
("devtools.netmonitor.har.pageLoadedTimeout", "2500");
Versions:
Firefox 43.0,
Python 2.7.8,
selenium 2.48.0,
robotframework 3.0,
robotframework-selenium2library 1.7.4,
harexporttrigger-0.5.0-beta.7
Not really a solution but a workaround: Autoexport is switched off, export is triggered programmatically as described here.
I wasn't aware of that, before. But now I think this is a far better approach because it is
more stable
performs better
allows more control
Settings:
devtools.netmonitor.har.enableAutoExportToFile, false
devtools.netmonitor.har.forceExport, false
extensions.netmonitor.har.enableAutomation, true
extensions.netmonitor.har.contentAPIToken, "test"
Ok, I'm implementing IAP into an iOs app and only some products in the store actually trigger the native purchase handling dialogs.
Background:
The app uses cocos2dx with javascript bindings for cross-platformability. We're dipping into the iOs native sectors to implement the store handling.
These calls all work correctly:
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[SKPaymentQueue canMakePayments];
[[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
A note on the last one. All product ids are checked and return as valid in the productsRequest:request didReceiveResponse:response callback but only if I don't include the bundle id in the identifiers that get sent. Most examples I saw said this was needed, but if included they all return as invalidProductIdentifiers. Could this be indicative of a problem?
So currently some products bring up the native purchase confirm dialog after their (previously verified) ids are passed to [[SKPaymentQueue defaultQueue] addPayment:payment]. Most of them simply do nothing afterwards. No callback on paymentQueue:queue updatedTransactions:transactions, no error code, no crash.
I can't see a pattern for why some work and most don't. At least one consumable, non-consumable and subscription work, so I don't think it's that. I found that if I break and step through the code pausing after [[SKPaymentQueue defaultQueue] addPayment:payment], there's a small chance a few products work more often, although it's not consistent. This lead me to think it may be a threading issue, but you can see what I've tried below and it didn't help.
Things I've tried:
Reading around SO and elsewhere, people suggested changing test users, clearing the queue with [[SKPaymentQueue defaultQueue] finishTransaction:transaction], and that Apple's Sandbox server sometimes 'has issues'. But none of this fixed it, and it strikes me as odd that I'm not getting crashes or errors, it just doesn't react at all to certain product ids.
Here's the actual call with some things I've tried:
- (void)purchaseProductWithId:(const char*)item_code
{
/** OCCASIONALLY MAY NEED TO CLEAR THE QUEUE **
NSArray *transactions = [[SKPaymentQueue defaultQueue] transactions];
for(id transaction in transactions){
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
}// */
// dispatch_async(dispatch_get_main_queue(),^ {
SKPayment *payment = [SKPayment paymentWithProductIdentifier:[NSString stringWithUTF8String:item_code]];
// [[SKPaymentQueue defaultQueue] performSelectorOnMainThread:#selector(addPayment:) withObject:payment waitUntilDone:NO];
[[SKPaymentQueue defaultQueue] addPayment:payment];
// } );
}
If there's any other code that could be useful let me know.
Thanks for your help.
Edit:
I've added the hasAddObserver check from this question and that's not the problem either.
Turns out it was a temporary thing. I'd hate to accuse Apple's sandbox servers of being flaky, but nothing was changed and then days later it suddenly worked.
So if you have a similar issue maybe take a break and come back to it later?
I am working on an intranet application that uses the Google Visualization API to produce charts.
My question is is there a way to determine if access to https://www.google.com/jsapi server is down or blocked due to the company use of iPrism and display that information simply to the user on the page.
I know iPrism dosn't block it on my machine but i'm not sure about the client machines or that it may change in the future.
Any help is aapreciated.
I don't think there is anything you can trigger of of a script tag failing to load, but you could try to catch the failure before calling google.load, maybe with something like this?
if (typeof(google) == 'object' && typeof(google.load) == 'function') {
google.load('visualization', '1', {packages:['corechart'], callback: drawChart});
}
else {
// display error message about failing to load jsapi
}
I have a unit test that creates an error condition. Normally, the class under test writes this error to the logs (using log4j in this case, but I don't think that matters). I can change the log level temporarily, using
Logger targetLogger = Logger.getLogger(ClassUnderTest.class);
Level oldLvl = targetLogger.getLevel();
targetLogger.setLevel(Level.FATAL);
theTestObject.doABadThing();
assertTrue(theTestObject.hadAnError());
targetLogger.setLevel(oldLvl);
but that also means that if an unrelated / unintended error occurs during testing, I won't see that information in the logs either.
Is there a best practice or common pattern I'm supposed to use here? I don't like prodding the log levels if I can help it, but I also don't like having a bunch of ERROR noise in the test output, which could scare future developers.
If your logging layer permits, it is a good practice to make an assertion on the error message. You can do it by implementing your own logger that just asserts on the message (without output), or by using a memory-buffer logger and then check on the contents of the log buffer.
Under no circumstances should the error message end up in the unit-test execution log. This will cause people to get used to errors in the log and mask other errors. In short, your options are:
Most preferred: Catch the message in the harness and assert on it.
Somewhat OK: Raise the level and ignore the message.
Not OK: Don't do anything and let the log message reach stderr/syslog.
The way I approach this assuming an XUnit style of unit testing (Junit,Pyunit, etc)
#Test(expected = MyException)
foo_1() throws Exception
{
theTestObject.doABadThing(); //MyException here
}
The issue with doing logging is that someone needs to go and actually parse the log file, this is time consuming and error prone. However the test will pass above if MyException is generated and fail if it isn't. This in turn allows you to fail the build automatically instead of hoping the tester read the logs correctly.
We have an application that was developed with Flash, AS2 and ColdFusion backend (remoting). I observed that when there was a database query failure, and that came in to Flash, the _result handler will be called (instead of _status), and the player hangs with the infamous unresponsive / abort the script error.
Doing a trace on the result produces nothing. Trying to enumerate properties in the result also produces nothing.
That's very strange. Does anyone have any idea about what could be causing this / how to solve it?
Use debug version of flash player in your browser if you don't use it already, most likely it will throw an exception popup.
Second thing is to install http://amfexplorer.riaforge.org/ and see what back-end sends, if anything.
If this doesn't help try putting result parsing code into try-catch and see where it blows up applciation:
try {
// statements
} catch (myErr) {
// statements
} finally {
// statements
}