Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 5 Jahren, 4 Monaten
Letzter Beitrag:
vor 5 Jahren, 4 Monaten
Beteiligte Autoren:
Ola, Fabrice Harari, Al, Frans, Ola (at another machine)

[WD16] How to know the test type the window is running in?

Startbeitrag von Ola am 04.04.2013 09:43

Hi all!

Is there any way to know how a window test was launched: is it a project test or a window test?



Hello Ola

As you are the one pressing either of the "GO" buttons you could always ask yourself which one did I press :rolleyes:

The InTestMode() command has a set of return values, one of which is "tmProject" to indicate how the test started so maybe you can use of those values.
The debugger may return a value for InTestMode on a stop ?


von Al - am 04.04.2013 10:48
Hi Al,

Luckily I still know - most of the time - which button I pressed :-), but does the program know it too? Checking through the docs it seems that not.

I just would have added some default code to a window initialization, to be executed if the window was called with the window test button, and therefore having passed the login screen.


von Ola - am 05.04.2013 10:55
Hi Ola

In the project init code (not run when testing a window only), you can do
in the window init code
if MyGlobalBoolean=false then//window alone

Best regards

von Fabrice Harari - am 05.04.2013 13:12
Thanks Fabrice

I started to think along the same lines, too. Something like hoisting a global login-flag in the login window and then calling the login before opening the window, if the login-flag is down.


von Ola (at another machine) - am 05.04.2013 13:59
Hello Ola

I tried the return values for the InTestMode() command in the debugger and they work.
If you start a window from the window "GO" button then if you Stop or Break the code execution, you can test the IntestMode(tmWindow) in the debugger and it will return True and false for IntEstMode(TmProject)

It also works if you setup and info() message in the Window Init code and info(InTestMode(tmwindow) will show 1

You could pass the whole thing to a global procedure in the init of any window

If InTestMode()
End //If InTestMode()

IF InTestMode(tmPage)
Info("Called from Page ")
IF InTestMode(tmProcedure)
Info("Called from Procedure")
IF InTestMode(tmWindow) THEN
Info("Called from Window GO")
IF InTestMode(tmProject) THEN
Info("Called from Project GO")
IF InTestMode(tmQuery) THEN
Info("Called from Query Go ")
IF InTestMode(tmReport) THEN
Info("Called from Report GO")
IF InTestMode(tmTest)
Info("Called from Auto Test GO")
END //IF InTestMode(tmTest
END //IF InTestMode(tmReport) THEN
END //IF InTestMode(tmQuery) THEN
END //IF InTestMode(tmProject) THEN
END //IF InTestMode(tmWindow) THEN
END //IF InTestMode(tmPage) THEN
END //IF InTestMode(tmPage) THEN


von Al - am 05.04.2013 14:15
Hi Ola

just a precision... as part of my "best practices" created during all those years, I stopped testing az window by itself quite some time ago...

As your project grows in complexity, you'll end up doing more and more stuff in the project init code and therefore your window tested alone will:
- either not work at all (db access, permissions, objects not initialized...)
- or work differently than when tested inside the project

At least that has been my experience

Best regards

von Fabrice Harari - am 05.04.2013 14:16
Hi Fabrice,

I am 100% sure that when I test a single window that the project ini-code is run.
So that couldn't be the problem.

von Frans - am 05.04.2013 17:33
Hi All

Thanks for the hints.
Frans is correct: the project ini code is run even when running a window test only.
Al gave the exact answer I was looking for, complete with excellent sample code.

My "problem" in this case was that I need to have the login data before opening some windows. I call the login window from the main menu's init code, and threfore it is not run when testing a separate window. I think I'll just move the call to login window to the end of the program ini code. Then I don't have to worry about this any more.


von Ola - am 09.04.2013 12:42
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.