Coded UI test Single Thread Apartment (STA) error occurred while executing [ClassCleanup] method -
why sta error while class performing clean-up method in coded ui test seems concrete test methods works fine. code looks ff:
[codeduitest] public class concretecuit : testbase { [classinitialize] public static void initialize(testcontext context) { //do init } [classcleanup] public static void cleanup() { //do clean-up - sta error!!! } [testmethod] public void concrete1crudtest() { //do ui test } [testmethod] public void concrete2crudtest() { //do ui test } }
and got following error below:
class cleanup method samplecuit.cleanup failed. error message:microsoft.visualstudio.testtools.uitest.extension.uitestexception: coded ui test running in single thread apartment (sta) mode of com. in mode, playback calls should happen testmethod thread , uitestcontrol should not shared across testmethods.. stack trace: @ microsoft.visualstudio.testtools.uitest.playback.screenelement.throwexceptionifcrossthreadaccess(iscreenelement uielement) @ microsoft.visualstudio.testtools.uitest.playback.screenelement.findallscreenelement(string queryid, int32 depth, boolean singlequeryid, boolean throwexception) @ microsoft.visualstudio.testtools.uitest.playback.screenelement.findscreenelement(string queryid, int32 depth) @ microsoft.visualstudio.testtools.uitesting.uitestcontrol.findfirstdescendant(string queryid, int32 maxdepth, int32& timeleft) @ microsoft.visualstudio.testtools.uitesting.searchhelper.getelement(boolean usecache, isearchargument searcharg) @ microsoft.visualstudio.testtools.uitesting.searchhelper.search(isearchargument searcharg) @ microsoft.visualstudio.testtools.uitesting.uitestcontrol.findinternal() @ microsoft.visualstudio.testtools.uitesting.uitestcontrol.findcontrolifnecessary() @ microsoft.visualstudio.testtools.uitesting.uitestcontrol.click(mousebuttons button, modifierkeys modifierkeys, point relativecoordinates) @ microsoft.visualstudio.testtools.uitesting.mouse.clickimplementation(uitestcontrol control, mousebuttons button, modifierkeys modifierkeys, point relativecoordinate) @ microsoft.visualstudio.testtools.uitesting.mouse.clickimplementationwrapper(uitestcontrol control, mousebuttons button, modifierkeys modifierkeys, point relativecoordinate) @ microsoft.visualstudio.testtools.uitesting.mouse.click(uitestcontrol control)
the top line of stack trace states problem: "... all playback calls should happen testmethod thread". later lines of stack trace show call of mouse.click
cleanup routine.
do not call ui actions classcleanup
method.
Comments
Post a Comment