I just started trying UIAutomation with tuneup.js. But I am unable to verify the Alert contents using following script.
test("Login Screen: Test Alert", function(target, app)
{
UIATarget.onAlert = function onAlert(alert)
{
var alert_title=alert.name();
assertEquals("Test", alert_title);
alert.cancelButton().tap();
}
}
);
The above code returns result as PASS even though expected result “Test” does not match the actual result (“Check Password”). The alert.cancelButton().tap(); will work.
Can anyone help me on this issue? Thanks in advance.
Your syntax is wrong is all!
UIATarget.onAlert = function onAlert(alert){}
Should be:
UIATarget.onAlert = function (alert){}
UIATarget.onAlert is a callback that is executed asynchronously with the rest of the test code. Any exception that gets raised from assertEquals will not be caught by the test code.
You should probably work around this by setting a global variable from within the alert handler, and checking that variable from your test code.
Related
Here is the pseudocode of my unit test:
int invocationCount
given(mock).willDo {
invocationCount++
return value
}
doSomeProcessing()
verify(mock)
doSomeMoreProcessing()
verifyCount(mock, 2)
At this point, invocationCount == 2, as expected. However, verifyCount fails, saying it was only called once. In addition, if I exclude the first verify call, the test passes as expected. It might be relevant to note that each verify call is capturing a new argument for assertion later.
My question is this: when the first verify() is called, is the mock's invocation count reset? If this is not the case, what could be happening?
Yes, verification only counts the matches since the last verification.
Further discussion can be found here: https://github.com/jonreid/OCMockito/issues/116
I am looking at some legacy C# code like this:
await Task.Run(() =>
{
_logger.LogException(LogLevel.Error, message, exception);
Thread.Sleep(500);
});
I created the following F# code but the Thread.Sleep is not getting hit:
Tasks.Task.Run(fun _ -> logger.Log(LogLevel.Warn, message)
Thread.Sleep(500))
Can someone tell me what I am doing wrong? I need maintain the method's signature.
Thanks in advance.
This is normally where you would use a asynchronous workflow. If you need to keep the function returning a Task, you can do this:
let someFunc (message : string) : Task =
async {
logger.Log(LogLevel.Warn, message)
Thread.Sleep(500)
} |> Async.StartAsTask :> Task
Looks like it is working, I am just getting an exception:
System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain. This can happen if the test(s) started a thread but did not stop it. Make sure that all the threads started by the test(s) are stopped before completion.
I am currently creating a Backbone.js and jquery Mobile web application and I have some calls to Backbone.model.fetch().
I have the proper success and error-callbacks, but there is some code that I want to execute no matter if the fetch was successfull or not.
Currently, I'm simply copying the common code. But I asked myself if there is any callback that is executed no matter what happens.
Like the try{} catch{} finally{} from C#.
Is there anything like that?
fetch() returns a 'Deferred Object'
see: http://api.jquery.com/category/deferred-object/
it's not really like try{} catch{}, but you can use .always() method to bind a callback which will be executed after the request is done (no matter if it was successful or not)
like so.
var doSomething = function () {
//will run after fetch() request is finished
};
collection.fetch().always(doSomething);
similarly, instead of passing success or error callbacks to fetch()'s options, in general it is encouraged to chain .done(), .fail(), or .then() methods to deferred methods(fetch, save...etc)
it seems there is an error in the code below, but where?
function cloneLoader(source:Loader):Loader
{
var clone:Loader = new Loader();
clone.loadBytes(source.contentLoaderInfo.bytes);
return clone;
};
clone.loadBytes is an asynchronous call. So you probably can't use the returned object right away.
Maybe try return Loader(ObjectUtil.clone(source));
There is no error in the code as such, nothing wrong with the syntax, it will work fine if source is a Loader.
What error message do you get?
I have a couple timers in a Flash application I'm building. They worked fine initially, but after building the application and adding more code to it, I'm suddenly getting these weird compiler errors. When I try to compile, I get 'error 1136: Incorrect number of arguments. Expected 0.' on the line of the Timer declaration, which looks like this:
var newTimer:Timer = new Timer(5000, 1);
I've tried declaring without arguments and adding them to the according properties like this:
var newTimer:Timer = new Timer();
newTimer.delay = 5000;
newTimer.repeatCount = 1;
When I do this I get 'error 1120: Access of undefined property newTimer.' on both of the delay and repeatCount lines. Any ideas as to what the problem could be?
Timer accepts two arguments so that "expecting 0" error is suspicious. Are you by chance exporting another MovieClip or object with a class name of "Timer"?
var newTimer:Timer = new Timer(5000, 1);