I'm trying to test my ability to login to an API. Naturally, that means I need my test classes to access my username and password. However, I'd like to put this project on public source control, so I can't share my username and password in the code (one would imagine). I would use command line arguments, since they're stored in a .user file (which can be kept out of source control without breaking the project for other users). However, those don't seem to actually get passed to test classes (at least, when I use Environment.GetCommandLineArgs()
, I don't see them). So how can I store my passwords locally without breaking the project for other users? Is there a way?
A common way to do is is as follows:
Add a pre-build build event that contains a command like this:
IF NOT EXIST "$(ProjectDir)\App.config" COPY "$(ProjectDir)\App-template.config" "$(ProjectDir)\App.config"
This now has this effect:
It is imperative for this method to work that you can ask your source control tool to ignore files that are present on disk or even in the project itself so that it doesn't automatically add it to a commit later after you've modified it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With