Inside my MsTests I have to reach and use a file in my project. So I am using Path.GetFullPath(#"......\name_of_file")
But when running the build I get a file not found error because the context of the path is the temp directory (C:\TeamCity\buildAgent\temp\buildTmp) instead of the checkout directory where all my files are (C:\TeamCity\buildAgent\work\e87255825b2f3eb1)
Is there a config to change that? Or a better way to do it?
I couldn't find a TeamCity option to specify the directory the unit tests should be run. Someone else might be able to help there.
However, I usually include files that are needed for the unit tests as embedded resources so that during execution you know for sure the file will always be accessible no matter where it is running from. You can easily get a Stream from an embedded resource and if you need to use an API that only takes a file name you can write the file to Path.GetTempPath().
I modified my tests to refer to the files like this:
string currentDir = new System.Diagnostics.StackFrame(true).GetFileName();
var workingFile = new FileInfo(currentDir);
string fileContents = File.ReadAllText(workingFile.Directory + #"\ResourceFolder\MyFile.xml");
I know this isn't a good way to do it, but this works for me locally and when called from TeamCity.
Related
I am migrating some integration tests from gradle to bazel for an application. As part of the integration test a resource is loaded like
final String resourcePath = SomeClass.class.getResource("/test.properties").getPath()
If I trace this code path, when I run this test from IntelliJ, for gradle, this path is an absolute path like
/Users/me/..../test.properties
However, in the case of bazel, it looks something like
file:/private/var/tmp/_bazel_me/4f1994ece960b360388a372b5e6aa4b2/execroot/project/bazel-out/darwin-fastbuild/bin/project/src/integrationTest/package/Test.jar!/test.properties
So this string resourcePath is provided to a framework that loads with
Files.exists(resourcePath)
This works for the absolute path but not for the jar based path. How do I get around this since I don't have any control over the framework code?
If you're using the resources attribute of java_test or java_library, then indeed the resources are packaged inside the jar for that target:
https://docs.bazel.build/versions/main/be/java.html#java_test.resources
It sounds like you might want to try the data attribute instead, which puts files in the runfiles directory (i.e., the directory where the test / binary is executed). See the answer here: how to find path to Java source code files from JUnit tests execution via Bazel
I have a Cypress downloaded in zip file for Windows and extracted locally and when I am trying to run any tests, seems like Cypress recurively trying to create an integration/cypress/integration.. folder and failing
Error: ENAMETOOLONG: name too long, stat
'C:\Users\user\work\sources\services\automation\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress\integration\cypress
Is there a workaround for that?
Have you tried change the default integration folder path in your cypress.json file?
Something like
integrationFolder: Another Path
if that solves the issue problably the integration Folder location was misconfigured
So I have a Jenkins job wherein as part of the build.
I run one script which creates a folder in the workspace say "test"
so the script runs fine and creates the folder test.
After this, I have a maven command wherein I want to access this test folder(as an argument) I am trying it as $workspace/test
but it's not working.
Can anyone guide if i am missing anything here
Can you give us more information - maybe code snippets?
I'm not sure what you mean with 'maven command' and '$workspace/test'
If you want use a variable in a pom.xml like:
<path>${workspace}</path>
you will have to assign it in the properties:
<workspace>...location...</workspace>
Otherwise you can use maven preassigned variables like
${basedir}/
I have seen the other 2 appends and added sonar.languages=COBOL to my sonar-project.properties file to no avail.
I think it's basically more a case of not understanding the documentation (or the latter never having been "idiot tested"").
My problem is as follows. My properties file contains the following entries:-
# sonar.sources=../../mfuser/seb/source/
sonar.sources=C:/mfuser/SEB/Source
sonar.cobol.file.suffixes=cbl,cpy
sonar.cobol.copy.suffixes=cpy
#
sonar.languages=COBOL
When I run the sonar-scanner bat file, I'm seeing output like this:-
WARN File C:\mfuser\seb\source\vvira20.cbl is ignored. It is not located in module basedir c:\sonar-scanner\bin
To me this gives the impression that I can point to the directory containing my COBOL code, but at the same time the actual code HAS to be in c:\sonar-scanner\bin. Surely, that can't be the case? If it is, what is the point with the sonar.sources entry in the properties file?
In addition, onece I get this working, is there some way of specifying a parm/wild card so as to analyze SPECIFIC files. I tried sonar.sources=C:/mfuser/SEB/Source/vno* but that didn't seem to make any difference.
Thanks
You ran sonar-scanner from its own directory instead of running from the project directory. As the documentation says:
Run the following command from the project base directory
sonar-scanner
This same documentation recommends to create the sonar-project.properties file at the root of the project directory and to set the "sonar.sources" property to a path which is relative to the sonar-project.properties file.
Alternatively, you may want to use the "sonar.projectBaseDir" property. See the documentation for analysis parameters.
Let me know about how to mavinize Folder Context in RCPTT!
FYI: I have created a folder context (my_folder_context.ctx referring to a remote folder). First I click "Apply" button after opening the .ctx file in RCPTT tool to copy the contents to AUT location than execute the test cases to get the test data.
But while automating the same I don't find any entry for *.ctx file in RCPTT-maven-plugin. For suites we have below:
<suites>
<suite>MyTestSuite</suite>
</suites>
...but the same I didn't find for *.ctx files or any way to refer the folder context from ECL script .
Yes the short answer is this is NOT possible as the foldercontext is obviously not a testcase. You can only add the test case inside test suit.And it does not make any sense to execute a foldercontext file which is not doing any thing and no result or report can be generated out of it.
By the way let me share few of my learning here:
1)Folder context can be used while recording time in rcptt but runtime it's of no use. Basically it's like a mapped directory for a remote location available inside your rcptt tool.
2)I had provided the test data location at runtime and the same I achieved through below:
Go to RCPTT->Run configurations ->VM Arguments append -D"testdatalocation" (without double quote) and provide below
in ECL script :
set-dialog-result Folder [substitute-variables "${system_property:testdatalocation}"]
or in your maven pom.xml file :
<vmArgs>
<vmArg>-Dtestdatalocation=D:\InputsForAutomation</vmArg>
</vmArgs>