Run Testcases which use setting of configuration file - configuration

I am running Testcases (typescripts files) from the command prompt and there only providing settings like browser selection and concurrency number. But I want to use common settings mentioned in TestCafe configuration file testcafe.js.
Can someone please help me with sample testcafe configuration file, and how to execute testcases to use settings mentioned in the configuration file.
const createTestCafe = require('testcafe');
createTestCafe('localhost', 1337,1338)
.then(tc=>{
testcafe= tc;
const runner=testcafe.createRunner();
return runner
.browsers(['chrome'])
.concurrency(3)
.run();
});

Create your .testcaferc.json configuration file in the same directory where you have your test script. TestCafe will find the config file and use it automatically. You don't have to specify it in your programming interface.
I recommend that you refer to the Configuration File topic where its options are described. You can find a complete configuration file example in the GitHub repository.

Related

Pylint nested pylintrc : Specify a configuration file

Goal
I want to use pylint without specifying the file path (just run pylint instead of pylint --rcfile=linter/.pylintrc), as I want to save all linter related files in a subfolder linter/.
I thought of adding a .pylintrc file at the root folder only a redirection to the actual config file linter/.pylintrc.
Exploration
The option rcfile seems to be what I look for, it doesn't seems to import the settings from the sub-folder. What am I missing ?
Proposed .pylintrc file for redirection:
[MASTER]
# Specify a configuration file.
rcfile=subfolder/.pylintrc
This is not supported in pylint see this pull request

google cloud functions: downloading a file to the root directory python 3.9

I have a file I need to get into the Google Cloud Function's directory for a multi-step problem. Matplotlib: Custom fonts in cloud functions using Python 3.9
I'm not sure how to do it. Do I do it as a function in cloud functions? or use the console terminal for the project? I tried that and looked in the root directory and there was nothing there. I can only change projects and not change to a specific function directory.
Can someone please show me how to put this file https://www.1001freefonts.com/balthazar.font into the function's file system so it can be called during execution?
When you deploy a Cloud Function to GCP, you can supply a ZIP file or a directory that contains your source code and additional artifacts/files that you may need.
To perform the deployment of the ZIP or directory, you will want to use the gcloud command. A good article on this is Deploying from Your Local Machine.
The detailed documentation on the CLI can be found at gcloud functions deploy.
In your example, you could create a directory that contains your source and your font file and both will be present in the context of the Cloud Function. I believe that if you want to reference the files, you will want to use the local current directory in your code. For example, instead of coding /myfontfile.font you might code ./myfontfile.font.
Here are some references to this technique:
Cloud Functions: how to upload additional file for use in code?

Codeception environment configuration not working

Codeception: Configuration file(s) placed in tests/_envs are not working. I am trying to run my acceptance tests in multiple environments (ex. dev, qa, staging, prod). So I have setup dev.yml, qa.yml, staging.yml and prod.yml files under tests/_env directory. Each of those separate environment I am overriding the WebDriver - url.
file - dev.yml
modules:
config:
WebDriver:
url: 'dev.mysite.local'
Then when I try to run the acceptance test suite using one of the environment, ex
./vendor/bin/codecept run acceptance --env dev
It doesn’t pull in the dev configuration, but instead uses the default configuration from acceptance.suite.yml file. What am I doing wrong?
There is a bug in the codeception/configuration.php file where a wrong regular expression has been used, which prevents .yml file from being loaded. However, dist.yml files loads just fine. They have already pushed a change for this bug.
In case you don't have this changeset, you can manually change it on your codeception/configuration.php file or simply use the dist.yml extension.
Wrong regex:
$envFiles = Finder::create()
->files()
->name('*{.dist}.yml')
->in($path)
->depth('< 1');
Correction:
$envFiles = Finder::create()
->files()
->name('*.yml')
->in($path)
->depth('< 1');
Thanks to sjableka for the answer posted on the Codeception repo.

PhpStorm: how to use project root variable or relative path in PhpUnit configuration?

I would like to setup PhpUnit in PhpStorm. I press 1. Edit Configurations... and would like to enter this parameter in field 2.
I am using phpunit.xml as configuration file and all want to use a relative path like:
phpunit.xml
or use project root variable like
$PROJECT_ROOT/phpunit.xml
But both options are not working for me.
Based on your screenshot (the place where you want to use it): use full path -- in project settings such path is stored relative to the project root anyway (unless you specify some file which is outside of the project, of course) and the full path then reconstructed when needed (e.g. when shown to you or when used as a parameter during tests execution).
I don't think you'll be able to achieve what you want via the project's Run/Debug configurations. What might help you is the Default configuration file setting in your default project settings, which can be used to define the PHPUnit configuration file to use by default, so you don't need to specify it via the Use alternative configuration file option in your Run/Debug configuration.
To set this, open your Default Settings window, then navigate to Languages & Frameworks -> PHP -> PHPUnit. In the Test Runner section tick the Default configuration file checkbox and specify the location where you keep your configuration file. If this file will always be in the same path relative to your project root, you can use the $PROJECT_DIR$ variable to define the project root. So if your PHPUnit configuration file is always in the root of your project, you might set this to something like $PROJECT_DIR$/phpunit.xml. When you create a new project, its Default configuration file variable will be set to the file offset from your project root, and you won't need to use the Use alternative configuration file option in your Run/Debug configuration.
If you're opening the same project in different locations on the same machine this should work for new projects without any problem, if you want to share this configuration across machines, you might need to try PHPStorm's Exporting and Importing Settings functionality.
I'm not sure if this directly solves your problem, and it's a few months late anyway, but maybe this will be useful for someone else who stumbles across this question... The above instructions were correct for my 8.0.3 installation on Linux.

Configuration path of Log4j2

I am trying to adopt Log4j2 to my project. Since my Java Application is packeted in a JAR file. I don't want "log4j2.xml" configuration packaged inside of JAR file. I am trying to learn how configuration file works from "http://logging.apache.org/log4j/2.x/manual/configuration.html"
But seems there is no clear instruction regarding altering the configuration file path of the Log4j2.
After googling about this topic I found something like "Referencing log4j config file within executable JAR" Referencing log4j config file within executable JAR, But this solution is not available any more according to "http://logging.apache.org/log4j/2.x/manual/migration.html" (if I understand it correctly).
So I am wondering if someone have any idea about this issue.
Thanks
You can set the system property to specify the configuration path.
set the
"-Dlog4j.configurationFile="D:\learning\blog\20130115\config\LogConfig.xml"
in VM arguments. replace
"D:\learning\blog\20130115\config\LogConfig.xml"
to your configuration path.
Put the log4j2.xml file in resource directory in your project so that the log4j will locate files under class path automatically.
Loading log4j2.xml file from the customized location-
You can use the System property/ VM arguments- Dlog4j.configurationFile=file:/path/to/file/log4j2.xml
This will work for any web application.
For some legacy applications, you can create a class for loading log4j2.xml/ log4j2.properties from the custom location on the machine like- D:/property/log4j2.xml
Using any of these approach,during application startup, the log4j2.xml file from the src/resources folder will be overridden by the custom location log4j.xml file.
Try using -Dlogging.config=Path_to_your_file