Seddryck / NBi

NBi is a testing framework (add-on to NUnit) for Business Intelligence and Data Access. The main goal of this framework is to let users create tests with a declarative approach based on an Xml syntax. By the means of NBi, you don't need to develop C# or Java code to specify your tests! Either, you don't need Visual Studio or Eclipse to compile your test suite. Just create an Xml file and let the framework interpret it and play your tests. The framework is designed as an add-on of NUnit but with the possibility to port it easily to other testing frameworks.
http://www.nbi.io
Apache License 2.0
106 stars 37 forks source link

Using the environment variable in the connection string for the database in the genbil #682

Open Longwinter93 opened 2 years ago

Longwinter93 commented 2 years ago

Hi, I usually load a set of my test cases from my database like: case load query 'Relative Directory\myQuery.sql' on 'Data Source=...';

However, I was wondering if it is possible to place the environment variable in the connection string for the database instead of 'Data Source=...'; For example: case load query 'Relative Directory\myQuery.sql' on 'environment name ="Database"';

Unfortunately, this example does not work. Obviously, I took a few tests, where I changed this syntax, but none of my ideas works..

Could you please tell me if it is possible to implement the environment variable in this connection string for the database? If so, would you be so kind as to advise me how to deal with it?

I would appreciate it if you could share any ideas with me.

Thanks in advance!

Seddryck commented 2 years ago

There is no support of environment variables within genbiL.

This should be implemented as a new feature.

Longwinter93 commented 2 years ago

Hi! Thank you for your answer.

It seems that this feature would be extremely useful and helpful.

Could you please tell me if you implement it soon ?

Should I create a new pull request about it ?

I would appreciate it if you could tell me about it.

Best regards, Lukasz

Seddryck commented 2 years ago

To be honest, I’m not working on Nbi at this moment. I’ve other urgent priorities.

Nevertheless, it’s not really complex to implement. Will try to find one hour to implement it this week.

If you want to work on it, feel free. I do believe that the right syntax woulld be something like env$:my Var without the quotes. Before pushing any code would be better to check that we are aligned on syntax.

On 8 Jun 2022, at 08:56, Lukasz @.***> wrote:

 Hi! Thank you for your answer.

It seems that this feature would be extremely useful and helpful.

Could you please tell me if you implement it soon ?

Should I create a new pull request about it ?

I would appreciate it if you could tell me about it.

Best regards, Lukasz

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.

Longwinter93 commented 2 years ago

Hi, Thank you for your advice and response !

I will try to handle this problem once again and inform you about it provided that it works.

If you find this solution earlier, I will be thankful if you share it with me.

Therefore, we keep in touch!

Best regards, Lukasz

Seddryck commented 2 years ago

I hope that this version is adding the feature. To reference an environment variable use the following syntax

case load query 'Relative Directory\myQuery.sql' on $env:Database;

where Database is the name of the environment variable.

Could you confirm that it's matching with your need? If yes, I'll merge and create a beta.

Longwinter93 commented 2 years ago

Hi!,

Thank you for your contribution to it.

I downloaded Framework.zip and UI.zip files in order to run my genbiL. Unfortunately, if I open my genbiL files with your syntax, I will encounter difficulties in opening it. This failure appears: "Object reference not set to an instance of an object".

However, if I open the normal genbiL files without this syntax, it will work.

I tried to open these nupkg files by Visual Studio , but it did not work as well..

Therefore, could you please try to fix it and inform me about it ? Then, I will test it.

If I run it wrongly, can you advise me how to open it properly to run my genbiL with your syntax ?

I would appreciate it if you could fix it.

Best Regards, Lukasz

Seddryck commented 2 years ago

Could you share your file?

Longwinter93 commented 2 years ago

Hi, Do you mean a genbiL file ?

If so, these codes are included there:

case load query 'Relative_Directory\myQuery.sql' on $env:Database;
template load file 'Relative_Directory\Template.nbitt';
suite generate;
setting default assert connectionString '<environment name ="A"/>';
setting default systemundertest connectionString '<environment name ="B"/>';
suite save 'Relative_Directory\Save.nbits';

If no, could you please tell me which ones you need ?

Seddryck commented 2 years ago

I published a new version that should be working: https://ci.appveyor.com/project/Seddryck/nbi/builds/43833902/artifacts

Longwinter93 commented 2 years ago

Hi, Thank you for your contribution to it. Could you please tell me which files I need to download from this link to try it ?

It seems that I should download Framework.zip and UI.zip. Is it correct ?

I would appreciate it if you could advise me which ones are necessary to test it.

Thanks in advance !

Seddryck commented 2 years ago

I'd say that UI.zip should be enough, changes are limited to genbiL.

Longwinter93 commented 2 years ago

Hi!,

I put this code, which I sent you, to a genbiL file and when I run my macro I received this information: "Exception generated during execution of the macro. connectionString The connection string cannot be null or empty."

I checked my environment variables in Windows and all of them has connection strings.

Could you please tell me how you modify your genbiL file that works properly ?

I am not aware where I made a mistake.

Best Regards, Lukasz

Longwinter93 commented 2 years ago

Hi!, I tried it once again and it works successfully!

I needed to change locally my environment variables in Windows with respect to this structure: 'Data source:...' Then, I needed to run this Genbi as a administrator.

I would like to inquire about this modification. Are you going to implement it in the upcoming release ? If so, when are you going to do it ??

Thank you for your contribution and aid in this modification!

Best Regards, Lukasz

Seddryck commented 2 years ago

Yes, it will be integrated into the next release. After some additional review, I'll write down some documentation and push to the develop branch. That will generate a new beta.

There is no difference between a beta and a release except the naming. I don't know when I'll publish a release.