|
From: iiley <iil...@gm...> - 2005-06-06 11:32:12
|
I want to do a test, it should be executed until the xml file is loaded. Is there a way in asunit? I saw the class TestCaseXml but can't figure out its usage, is here any tips? Thanx. |
|
From: Luke B. <lb...@gm...> - 2005-06-07 05:55:58
|
Great Question -
Yes.
The easiest way is to use com.asunit.util.TextFile. You can check that
class for required params and whatnot. The important thing is that
when the file is loaded, it will trigger an "onTextFileLoaded" on the
object that is set as it's callback. This should be your concrete
TestCase.
Your Test case will need some methods like the following:
private var mockData:TextFile;
private var instance:YourClass;
// Override the run function and request the XML
private function run():Void {
// I usually put my Mock data into the same package as my
Class Under Test (CUT)
mockData =3D new
TextFile("com/yourdomain/yourproject/YourClassMock.xml", this);
}
// Once the XML is loaded, call super.run()
// It's that simple...
public function onTextFileLoaded(txtFile:TextFile):Void {
super.run();
}
public function setUp():Void {
// Make a deep clone of your data in case any of your tests
make changes to it.
var safeDataInstance:XML =3D mockData.cloneNode(true);
instance =3D new YourClass();
}
I hope that helps!
Luke Bayes
www.asunit.com
|
|
From: Luke B. <lb...@gm...> - 2005-06-07 06:00:43
|
> But another problem, i use Sys.println to print the text of my xml > file, but there is any thing viewed on AsUnit Ui, i'm confused by that > but i guess the reason is that it's a html TextField just now. So i > just post it here maybe some one later will get same problem with > mine, then he/she can know why. And...is html enable is really needed > for AsUnit Ui output textfiled? No problem there (I hope) Sys.println was originally implemented to work within the Flash MX 2004 IDE. It should talk directly to the integrated Output panel if you're using the IDE. If you're NOT using the Flash IDE - or if you just plain want to see the output somewhere else... There is a checkbox in the lower left area of the UI that says, "show Sys.println". You should be able to select that checkbox and all of your Sys.println statements should then appear in the newly introduced text area. If that doesn't work for you - please let us know as that would then be a bug! Thanks for the feedback -=20 Luke Bayes www.asunit.com |
|
From: iiley <iil...@gm...> - 2005-06-07 06:38:42
|
>If you're NOT using the Flash IDE - or if you just plain want to see
>the output somewhere else...
I am using FAME, and with PHPEclipse plugin, i can view AsUnit Ui in
my eclipse window.
> There is a checkbox in the lower left area of the UI that says, "show
> Sys.println".
>=20
> You should be able to select that checkbox and all of your Sys.println
> statements should then appear in the newly introduced text area. If
> that doesn't work for you - please let us know as that would then be a
> bug!
I did selected the checkbox:), my meaning is that, it can't show
string with xml tags, i think this is because the AsUnit Ui's output
text field are enable to view html, so that xml strings will be
considered a wrong html, then nothing we can see on the output text
field if we just print a xml string.(for example:
Sys.println("<Seeme/>")). Am i right? i think this may puzzle many
people, they print some thing, but can't see them, like me, it puzzled
me very much today:).
|
|
From: Luke B. <lb...@gm...> - 2005-06-07 17:54:01
|
aaaah... Nice catch! We'll need to take a look at that for the next release.... We actually do some work with escape/unescape... But you might be able to make it work by doing something hacky like: escape(myXml.toString()); That may not work because we might already be doing that - and then automatically unescaping it on the other side of the local connection. This is a pretty big issue for sure - I'm going to escalate this as a very high priority for the next release. Thanks for the feedback - and especially the clarification! Luke Bayes www.asunit.com |
|
From: iiley <iil...@gm...> - 2005-06-08 13:28:33
|
Thank for your tips, yes, "escape(myXml.toString());" works, but it
replace "<","/"... to some like "%xx", it is not very good look.
Then i wrote a little tool today(Only 4 little class), it is useful to
me, maybe it is useful for some others too, I named it
BLog(Bridge/Switcher Log), you know some time you want to log message
only use Sys.println or trace, This is easy if you use TRACE with
MTASC, but ... then you want to do a more particular log, for example,
you want to view logs with different color between log, debug,
warning, error, you will changed all TRACE to the specified Flashout
methods, is that troublesome(you have to replace all TRACE sentences)?
you know TRACE only can replaced by one method. So i did things this
way:
TRACE("Some trace.");
TRACE("Some debug.", "DEBUG");
TRACE("Some error..", "ERROR");
Then use DBlog.handleLog to replace TRACE(through mtasc compile param
-trace), TRACE("Some debug.", "DEBUG"); will trace as a debug,
TRACE("Some trace."); will trace as normal, etc...
You can see the particular usage and download this little tool here:
http://www.aswing.org/tools/b_log.html
Hope this can help some.
2005/6/8, Luke Bayes <lb...@gm...>:
> aaaah...
>=20
> Nice catch!
>=20
> We'll need to take a look at that for the next release....
>=20
> We actually do some work with escape/unescape... But you might be able
> to make it work by doing something hacky like:
>=20
> escape(myXml.toString());
>=20
> That may not work because we might already be doing that - and then
> automatically unescaping it on the other side of the local connection.
>=20
> This is a pretty big issue for sure - I'm going to escalate this as a
> very high priority for the next release.
>=20
> Thanks for the feedback - and especially the clarification!
>=20
>=20
> Luke Bayes
> www.asunit.com
>=20
> -------------------------------------------------------
> This SF.Net email is sponsored by: NEC IT Guy Games. How far can you sho=
tput
> a projector? How fast can you ride your desk chair down the office luge t=
rack?
> If you want to score the big prize, get to know the little guy.
> Play to win an NEC 61" plasma display: http://www.necitguy.com/?r
> _______________________________________________
> Asunit-users mailing list
> Asu...@li...
> https://lists.sourceforge.net/lists/listinfo/asunit-users
>
|
|
From: Luke B. <lb...@gm...> - 2005-06-08 16:33:19
|
Hey iiley, Thanks for the post! If you publish that little util under an open source license, you can put some word out at www.osflash.org. Luke Bayes www.asunit.com |
|
From: iiley <iil...@gm...> - 2005-06-09 04:06:33
|
Yup, thanks for your advise Luke, i post the util to osflash list. 2005/6/9, Luke Bayes <lb...@gm...>: > Hey iiley, >=20 > Thanks for the post! >=20 > If you publish that little util under an open source license, you can > put some word out at www.osflash.org. >=20 >=20 > Luke Bayes > www.asunit.com > |
|
From: Ali M. <ali...@gm...> - 2005-06-14 04:36:16
|
Hey there, I'm re-reading "Test-Driven Development by Example" (http://www.amazon.com/exec/obidos/tg/detail/-/0321146530/qid=3D1118722781/= sr=3D8-1/ref=3Dpd_csp_1/104-5276191-3223133?v=3Dglance&s=3Dbooks&n=3D507846= ) and using a suggestion on page 148 that I'm finding pretty useful. I thought I'd share it with the group. The suggestion is to end every programming session by leaving your last test broken. This way, when you sit back down to code again you have a specific place to start. You jump straight back into the train of thought you had when you stopped programming last. I've found technique to be a very useful way to keep my train of thought straight from one day to the next. Funny thing is that I'm actually writing this email because I forgot to leave a test broken the last time I was at the computer. I didn't know where to start, so I ended up writing this email. Pretty silly side-track... Have fun. Ali |