After searching here and with google, I didn’t find anything helpful
I wrote a unit Test and need to receive data from my database, but it doesn’t receive.
Here is my code:
class GGPUnitTest_01 extends SysTestCase
public void CreateDeleteContractFolder()
select firstonly oldFolder ;
the red line has to call one record.
I tried different things like
select firstonly oldFolder where oldFolder.RecId>0;
but it doesn’t receive any data.
When I look into the table, using SQL Management Studio I find about 10 lines of data.
What am I doing wrong?
Is it possible, I am connected to a wron database? I need to run the unittest on the same database, as all my debugging of the AX code.
thanks for any help.
It seems that you test depends on pre-existing data in database, but you didn’t specify in which company. SysTestCaseDataDependencyAttribute might help.
I added a setup methid, which creates one recoed. This record I can receive.
So I see, the database, I use is empty.
Bu I want to run the unit tests on a not empty database.
How can I connect my Unit Test Project to a specific database?
You can’t suddenly switch to another database. The database is specified in the environment configuration and everything in this environment (including unit tests) uses this database.
Are you aware of the concept of companies in F&O? You can have several companies with isolated sets of data. For example, you may have customers in company USMF, but when you switch DAT, you won’t see any. If you look into the database, you’ll see that are CustTable records with DataAreaId=USMF, but none with DataAreaId=DAT. As you see, just counting the records isn’t sufficient - you must pay attention to DataAreaId as well. And there is one more similar concepts: partitions.
If you don’t specify another company in SysTestCaseDataDependencyAttribute, your tests will be executed in DAT company.
Dear Martin,Yes, using a company with the correct data and using SysTestCasDataDependency did help me out.
Thank You for Your help.