How to check the use of conditional definitions if the application is Firemonkey one?

I am using DUnit. It has a VCL GUITestRunner and a TextTestRunner console.

In the module used by the Firemonkey and VCL Forms applications, I would like to get the following:

  • If the application is Firemonkey, if the target is OS X, and runs on OS X -> TextTestRunner
  • If the Firemonkey application, if the target is 32-bit Windows, runs on Windows -> AllocConsole + TextTestRunner
  • If the application is VCL → GUITestRunner

{$IFDEF MACOS} TextTestRunner.RunRegisteredTests; // Case 1 {$ELSE} {$IFDEF MSWINDOWS} AllocConsole; {$ENDIF} {$IFDEF FIREMONKEY_APP} // Case 2 <--------------- HERE TextTestRunner.RunRegisteredTests; {$ELSE} // Case 3 GUITestRunner.RunRegisteredTests; {$IFEND} {$ENDIF} 

What is the best way to get Case 2 to work?

+4
source share
2 answers

There are no built-in conditional expressions that tell you if the FrameworkType project is as specified in the .dproj, VCL, or FMX file. As far as I know, you cannot include this setting in the code. Remember also that it is quite possible, although, of course, not the main one, to have an application that uses both VCL and FMX. This is really not a condition.

Therefore, I recommend that you declare your own conditional definition, which controls whether you are using a GUI runner or a text runner.

In fact, you apparently already have some kind of mechanism for this. You are dialing the code with the unit GUITestRunner . This means that it must be in uses in the same file as the code in the question. How do you conditionally include a GUITestRunner in a uses clause?

Note. The same question was asked on the Embarcadero forums: https://newsgroups.embarcadero.com/message.jspa?messageID=400077

0
source

use {$IF Defined(MSWINDOWS)}

instead of {$IFDEF MSWINDOWS}

because {$IFDEF MSWINDOWS} does not work correctly in Firemonkey VCL applications.

-2
source

Source: https://habr.com/ru/post/1435462/


All Articles