-
Notifications
You must be signed in to change notification settings - Fork 6
Testing
NimbleTemplate uses Github Actions as the CI, the workflow files are located under the .github/workflows/ directory.
There are 2 types of tests, Template tests and Variant tests
All test files are located under test/
directory.
.
├── ...
├── test
│ ├── ...
│ ├── nimble_template
│ │ └── addons
│ │ │ ├── ...
│ │ │ ├── common_mix_phoenix_addon_test.exs
│ │ │ └── variants
│ │ │ │ └── mix
│ │ │ │ │ ├── ...
│ │ │ │ │ └── mix_addon_test.exs
│ │ │ │ └── phoenix
│ │ │ │ │ └── common_phoenix_addon_test.exs
│ │ │ │ │ └── api
│ │ │ │ │ │ ├── ...
│ │ │ │ │ │ └── api_addon_test.exs
│ │ │ │ │ └── live
│ │ │ │ │ │ ├── ...
│ │ │ │ │ │ └── live_addon_test.exs
│ │ │ │ │ └── web
│ │ │ │ │ │ ├── ...
│ │ │ │ │ │ └── web_addon_test.exs
NimbleTemplate supports 4 variants:
- Mix
- Web
- API
- Live
A Mix project could be either a Standard project or a Custom project.
mix new awesome_project
mix new awesome_project --module=CustomModuleName
mix new awesome_project --app=custom_otp_app_name
mix new awesome_project --module=CustomModuleName --app=custom_otp_app_name
Each project could include a supervision tree
.
mix new awesome_project
mix new awesome_project --sup
mix new awesome_project --module=CustomModuleName --app=custom_otp_app_name
mix new awesome_project --module=CustomModuleName --app=custom_otp_app_name --sup
Adding it all together, totals to 4 variant test cases.
- Applying the
Mix variant
to aStandard Mix project
- Applying the
Mix variant
to aCustom Mix project
- Applying the
Mix variant
to aStandard Mix project with the --sup option
- Applying the
Mix variant
to aCustom Mix project with the --sup option
A Phoenix project could be either a Web, LiveView, or API.
- Web variants support HTML and Assets.
mix phx.new awesome_project --no-live
- LiveView projects include HTML and Assets configuration.
mix phx.new awesome_project
- API variants do NOT support HTML and Assets configuration.
mix phx.new awesome_project --no-html --no-assets --no-live
- Custom project variants allow us to modify the app name or module name.
# Use CustomModuleName
mix phx.new awesome_project --module=CustomModuleName
# Use custom OTP app name
mix phx.new awesome_project --app=custom_otp_app_name
# Use custom module and app name
mix phx.new awesome_project --module=CustomModuleName --app=custom_otp_app_name
So it ends up with 6 project types:
Web project
- Standard (
mix phx.new awesome_project --no-live
) - Custom (
mix phx.new awesome_project --no-live --module=CustomModuleName --app=custom_otp_app_name
)
API project
- Standard (
mix phx.new awesome_project --no-html --no-assets --no-live
) - Custom (
mix phx.new awesome_project --no-html --no-assets --no-live --module=CustomModuleName --app=custom_otp_app_name
)
LiveView project
- Standard (
mix phx.new awesome_project
) - Custom (
mix phx.new awesome_project --module=CustomModuleName --app=custom_otp_app_name
)
Putting it all together, there are 8 variants of test cases.
- Applying the
API variant
to aStandard Web project
- Applying the
API variant
to aCustom Web project
- Applying the
API variant
to aStandard API project
- Applying the
API variant
to aCustom API project
- Applying the
Web variant
to aStandard Web project
- Applying the
Web variant
to aCustom Web project
- Applying the
Live variant
to aStandard LiveView project
- Applying the
Live variant
to aCustom LiveView project
Make sure the Phoenix version is the same between local development and CI, otherwise there will be some error in the unit test.
- Phoenix version on CI can be found in:
.github/workflows/test_template.yml
- Install a correct Phoenix version on local via command:
mix archive.install hex phx_new __PHOENIX_VERSION__
Developed by Nimble