fishon 0 Posted April 9, 2020 Hello, I am just getting started with DUnitX and Delphi for that matter. I have a simple Hello World Delphi project that includes a test case using DUnitX from exercism.io. When I compile it however I get error "Cannot resolve unit name" for; System.SysUtils DUnitX.Loggers.Console, DUnitX.Loggers.Xml.NUnit I also get an "Undeclared identifier" error for; TDUnitXConsoleLogger TDUnitXXMLNUnitFileLogger But I'm guessing these are declared in the above units. This is the code that has these errors; program HelloWorld; {$IFNDEF TESTINSIGHT} {$APPTYPE CONSOLE} {$ENDIF}{$STRONGLINKTYPES ON} uses //System.SysUtils, // for some reason this line cannot be resolved in my // RAD Studio 2010 SysUtils, {$IFDEF TESTINSIGHT} TestInsight.DUnitX, {$ENDIF } DUnitX.Loggers.Console, DUnitX.Loggers.Xml.NUnit, DUnitX.TestFramework, uHelloWorldTests in 'uHelloWorldTests.pas', uHelloWorld in 'uHelloWorld.pas'; var runner : ITestRunner; results : IRunResults; logger : ITestLogger; nunitLogger : ITestLogger; begin {$IFDEF TESTINSIGHT} TestInsight.DUnitX.RunRegisteredTests; exit; {$ENDIF} try //Check command line options, will exit if invalid TDUnitX.CheckCommandLine; //Create the test runner runner := TDUnitX.CreateRunner; //Tell the runner to use RTTI to find Fixtures runner.UseRTTI := True; //tell the runner how we will log things //Log to the console window logger := TDUnitXConsoleLogger.Create(true); runner.AddLogger(logger); //Generate an NUnit compatible XML File nunitLogger := TDUnitXXMLNUnitFileLogger.Create(TDUnitX.Options.XMLOutputFile); I installed & configured DUnitX as per here so have the DUNITX user environment variable in RAD Studio 2010 set to the path of the source and added it to the Delphi Library path. I've used SysUtils in other exercise programs without prefixing it with "System." and it worked (and works here) fine. Also I do see DUnitX.Loggers.Console.pas and DUnitX.Loggers.Xml.NUnit.pas in DUnitX's source path. So I'm guessing my IDE is not properly setup somehow to resolve fully qualified unit names but I'm not sure where/how to fix this. Share this post Link to post
Vincent Parrett 762 Posted April 10, 2020 Unit namespace prefixes for the RTL/VCL etc were only introduced in XE2 As for DUnitX, my guess there is something wrong with the DUNITX variable, either the value it has or how it's referenced. Have a look at the Messages built tab, the dcc command line args should give you a clue what the library paths/search paths are. Also my suggestion is to never use the Library path and always use the project's Search Path. The DUnitX project wizard actually adds $(DUnitX) to the project's search path for you. Lastly, DUnitX really pushed the D2010 compiler to it's limits, so if you are at all able to, I would use a newer version of delphi! Share this post Link to post
fishon 0 Posted April 10, 2020 Hello Vincent, Thanks for your reply. So in the Messages pane at the bottom, in the Build tab I get; Quote [DCC Fatal Error] DUnitX.TestDataProvider.pas(32): F1026 File not found: 'System.Classes.dcu' When I double click this line it opens up this file which is a source file of DUnitX and red highlights line 32; uses System.Classes, This is the same problem as with System.SysUtils. In Project Options window for Delphi Compiler I tried specifying "System" for either "Default namespace" or "Namespace prefixes" fields and then compiling but the error was still there. So what you're saying is the only way to resolve these "standard" unit names in RAD Studio 2010 is I would have to go through this exercise project's and ALL DUnitX's source files and get rid of "System." from their uses lines. Emm..... not sure I wanna do all that especially in someone else's code. As for the DUnitX units unable to be resolved $(DUNITX) was never in project search path originally when I downloaded this exercise project. Only when I added it to Library Path for Delphi Library - Win32 did it get inherited into project search path. When I removed it from this library path it got removed from project's search path. When I then added $(DUNITX) to the project's search path and compiled I still got same errors. So I think I'll try Delphi Community Edition to avoid these issues. The only reason I'm using 2010 is my employer is using it but since I want to only run these exercism.io Delphi examples to learn the language I guess I could do it in the free Community Edition. Is it the same version as the latest payed one (10.3.3) just without some additional features? Share this post Link to post
Vincent Parrett 762 Posted April 10, 2020 The System.Classes issue is a but, I have just pushed a fix for this. I don't have D2010 installed at the moment so am not able to test with it. That file was added in Aug 2018 and no one has reported this issue until now, which suggests not a lot of D2010 users using DUnitX. If you downloaded the project rather than creating it with wizard then I can't do much about the search path. As for he community edition, I have never used it so not sure whether it includes DUnitX (it's bundled with the full versions these days). Share this post Link to post
fishon 0 Posted April 13, 2020 Seems you reshuffled the files somewhat. I downloaded a new zip and no longer see any code files in the main folder. I tried installing the DUnitX_IDE_Expert_2010.dproj project from the Experts sub-folder but it gave this upon compile; Quote [DCC Fatal Error] DUnitX.Expert.CodeGen.SourceFile.pas(31): F1026 File not found: 'DUnitX.inc' Share this post Link to post
Vincent Parrett 762 Posted April 14, 2020 On 4/14/2020 at 2:11 AM, fishon said: Seems you reshuffled the files somewhat. I downloaded a new zip and no longer see any code files in the main folder. I tried installing the DUnitX_IDE_Expert_2010.dproj project from the Experts sub-folder but it gave this upon compile; Yes, I posted about that a few days ago You will need to adjust your DUNITX variable to add \Source as the source code was moved into a subfolder. Share this post Link to post