I have a scenario where its step definitions resides in multiple files. For instance the login step resides in login_steps.rb and a search related step resides in search_steps.rb
Cucumber outputs undefined steps for any step that is not in login_steps.rb. The step definitions are run only when its present in login_steps.rb. Is it required to place all the step definitions of a scenario in the same file?
My folder structure
Project folder
└─ features
├─ pages
├─ scenarios
├─ step_definitions
└─ support
Command I used:
cucumber -r features features\scenarios\Test.feature
The whole point to Cucumber and the POM is that you have flexibility and do not need to re-write your steps per feature file. This is what my directory structure looks like:
Root
- features
- step_definitions
- step_definition.rb
- support
- env.rb
- lib
- BasePage.rb
- feature.feature
Basically, with this directory structure, it doesn't matter where your step definitions are AS LONG AS YOU REQUIRE THE SPECIFIC PAGE YOU'RE REFERENCING (your BasePage.rb file, for example)
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'pages', 'BasePage')
And /^I do something$/ do
#page = BasePage.new(#test_env)
#page.verify_el(css)
end
I'm not familiar with the specifics of RoR and cucumber, but I do use cucumber-jvm. Using steps from different files is supported. Note the documentation https://github.com/cucumber/cucumber/wiki/Cucumber-Backgrounder#where-do-i-put-tests specifically mentions it.
Sorry I can't be more help with the specific issue, but what you are trying to do (use step from different files) is workable.
This might be a "violation" but I would combine the answers from Whitney Imura and Dave W just to make the answer more clear...
You ask:
"Is it required to place all the step
definitions of a scenario in the same file?"
No. You can place your step definitions in logically distinct files within various folders, as you see fit (example below). After all, it is just ruby code.
Essentially Your command is correct for running an individual feature that has step definitions in various other folders...
cucumber -r features features\entities\entity.feature
If you do not run it as above, you will get missing stepdefs... Here I execute tests on a current project as a means to demonstrate:
cucumber
60 scenarios (14 undefined, 46 passed)
409 steps (32 skipped, 26 undefined, 351 passed)
cucumber -r features
60 scenarios (60 passed)
409 steps (409 passed)
As described in the Cucumber documentation, you can arrange your tests to suite your logical breakdown of your features:
|__ features
| |__ entities
| | |__ entity.feature
| | |__ step_definitions
| | |__ anything.rb
| | |__ entity_steps.rb
| |__ locations
| | |__ location.feature
| | |__ step_definitions
| | |__location_steps.rb
| |__ sites
| | |__ step_definitions
| |__ step_definitions
| | |__ local_assert_steps.rb
| | |__ local_crud_response_steps.rb
| | |__ local_email_steps.rb
| | |__ local_file_steps.rb
| | |__ local_script_steps.rb
| | |__ local_steps.rb
| | |__ local_web_steps.rb
` | |__ local_xml_file_steps.rb
|__ support
|__ env.rb
|__ local_env.rb
|__ local_transforms.rb
Related
I am trying to serve my frontend using the Gin framework. It is a small project which would make maintenance easier having it as a single binary.
The project structure looks like this:
Project
|
+-- backend
| |
| +-- backend (binary)
|
+-- frontend
| |
| +-- dist
| |
| +-- package.json
|
+-- Procfile
|
+-- .gitlab-ci.yml
Currently I am serving the fronend like this:
r.Use(static.Serve("/", static.LocalFile("../frontend/dist", false)))
For local dev this works fine and I did not have any issues. If I deploy this with my gitlab-ci pipeline it fails as I do not upload the ../frontend/dist directory. I looked at the pkgr library which should help me achieve my goal.
My issue is I can not get it to work with the Gin framework. Current snippet:
test := pkger.Dir("../frontend/dist")
r.Use(static.Serve("/", static.LocalFile("../frontend/dist", false))) <- compiles but does not serve frontend
r.Use(static.Serve("/", static.LocalFile(test, false))) <- Does not compile
Is there an easier way to achieve my goal?
The problem is when you deploy the project to Heroku (I supposed you are using Heroku because of the tag you are using) it compiles the Go to a binary.
The binary is running in the root folder of the project and ../frontend is not in the same path as the development enviroment anymore.
Something like this:
Project
|
+-- backend
| |
| +-- backend (binary)
|
+-- frontend
| |
| +-- dist
| |
| +-- package.json
|
+-- Procfile
|
+-- .gitlab-ci.yml
|
+-- project binary <---- here
So the correct path is ./frontend/ (see one dot)
You can set an environment variable to set the correct path.
As you are using Vue, you can set for the development environment a dev-server with a proxy pointing to backend. Then when building for production you can make Vue compiles to a specific folder that is hardcoded and served by the backend.
I decided to push a .NET Standard class library to an existing local NuGet repo at my workplace.
I did it by having the NuGet package automatically pushed after the build in Visual Studio:
nuget push [PACKAGE_FILENAME] -Source [REPO_ON_THE_NETWORK]
Prior to my push, there were 3 pre-existing packages for other projects in the repo. After my push, the only project visible - via the NuGet Package Manager UI in Visual Studio - was the one I just pushed. I can consume my project from the NuGet repo without issues.
I took a look in the folder itself on the network, and this is what I saw:
[ ] Repo
|
|_ [ ] Proj1
| |
| |_ [ ] v1.0.0
| | |
| | |_ [ ] lib
| | | |
| | | |_ [ ] net20
| | | | |
| | | | |_ .dll
| | | | |_ .pdb
| | | |
| | | |_ [ ] net46
| | | |
| | | |_ .dll
| | | |_ .pdb
| | |
| | |_ .nupkg
| | |_ .nupkg.sha512
| | |_ .nuspec
| |
| |_ [ ] v1.0.1
| |
| |_ .nupkg
| |_ .nupkg.sha512
| |_ .nuspec
|
|_ [ ] MyRecentlyPushedProj
|
|_ .nupkg
I have three questions:
Why are the folder's organized in such different ways? Notice how one folder has a sub-folder with the actual project binaries, while the others don't. Also notice how my recently-pushed project lacks everything except for the NuGet package file.
When we manually delete the recently-pushed project from the repo, then the old projects reappear in the NuGet Package Manager UI. Does having differently-organized folders mess with NuGet's ability to scan the repo? Has the way NuGet organizes the projects changed over time (with newer versions)?
How am I able to consume the recently-pushed project successfully without the folder containing any of the binaries?
From the hierarchy tree you drew, I can see some differences:
Your package doesn't come with a version.
Your package doesn't have a lib folder.
Now, there are two ways of publishing a NuGet package with NuGet CLI: push and add.
The main difference is that add is for non-HTTP package source (as stated on MSDN) and that it publishes the package in a hierarchic manner, while push doesn't always (and it usually depends on how the feed was initialized).
My recommendation is that you check the documentation I added, and based on that decide whether to use one command or the other. From what I can gather, you should use add.
Hope this helps.
I currently want to add some self written classes ("mycode.cpp" and "mycode.hpp") to a big existing C++ project that is configured with Cmake. These classes are located in "myfolder" which is located in the "lib/pointrender" folder of the existing project (see dummy hierarchy below).
|- libs
| |- core
| | |- ...
| |- pointrender
| |- myfolder
| | |- mycode.cpp
| | |- mycode.hpp
| |- existingclasses.cpp
| |- existingclasses.hpp
| |- project.cmake
|- CMakeLists.txt
In the CMakesLists.txt the pointrender folder is declared as a subproject.
declare_subproject(libs/pointrender)
How do I best add my code to the existing cmake configuration? Do I add it as a subfolder in the project.cmake with a seperate CMakeLists.txt in myfolder? Or do I best add it as a subproject with a seperate project.cmake file? What's the difference?
This project.cmake is being include()d be some CMakeLists.txt and get's executed as part of it. Authors of project you are using rolled this out for some reason, so it's probably better to use their infrastructure to add custom code.
The usual way to do this is writing your own CMakeLists.txt and add_subdirectory()ing it from the upper level.
If you wish more details you should update your question with project.cmake contents.
I'm trying to create a war that is to be deployed in an EAR and that should contain only images.
My war source organization is as follows :
+---src
| +---main
| | +---java
| | +---resources
| | | \---META-INF
| | | \---resources
| | | \---images
| | | placeholder_image.jpg
| | | placeholder_template.png
| | |
| | \---webapp
| | \---WEB-INF
| \---test
| +---java
| \---resources
and my war effective organization is
+---META-INF
\---WEB-INF
\---classes
\---META-INF
\---resources
\---images
placeholder_image.jpg
placeholder_template.png
The images I want to serve are in the src/main/resources/META-INF/resources/images folder.
I package this war using maven-war-plugin.
Under which url will those images be available on my local machine, provided my war is indicated as available under the http://localhost:8080/myapp/ path ?
None. Content from WEB-INF is not statically served, resources is for classpath resources. You need to put the images (folder) directly under webapp or add an servlet that serves the content.
This depends on whether you deploy the war in a Servlet-3-compatible container like Tomcat 7 or Jetty 8.
If so, your resources should be visible under http://localhost:8080/myapp/images/....
See also this post, where the only difference is that the resources are packaged in a jar. For jars, this feature makes more sense than for WEB-INF/classes, as, like the first answer points out, you should simply put your resources directly into src/main/webapp if they are located in the same Maven module.
I'm looking for a quick way, for any given multi-module project, to show a quick overview of the project hierarchy including only the modules in the project, excluding external dependencies.
eg for a project
project root
+- A
+- B
+- C
+- D
+- E
+- F
+- G
+- H
I would like to see a quick, single screen view for A-H (like it is depicted here) that gives me a fast digestible view to get an idea of a project structure. Ideally it would be command line output, not a platform specific solution (I note there is a tool for VisualStudio).
mvn dependency:tree is great but too verbose for this case, I suppose I could grep and cut the output apart but feels like there should be an easier way (ie another plugin).
You can filter the dependency tree: http://maven.apache.org/plugins/maven-dependency-plugin/examples/filtering-the-dependency-tree.html
So, if your group ID was com.foo.bar, you could get the projects in that group ID with:
mvn dependency:tree -Dincludes=com.foo.bar
Assuming all of your project's modules are within that group, that would cover your use case.
You could try this module here: MavenStructurePlugin
I had the same problem as you did and found it quite useful.
The output is pretty much what you seem to want:
test
|
|__ a
|
|__ b
|
|
\__ c
|
|__ d
|
|__ e
|
|__ f