Software Engineering Final
Know the three types of major tests in Rails and what they are used for
-Feature Specs: Tests that check that the application exposes a particular feature to the user. Used for "happy paths" -Request Specs: Tests that use HTTP to make direct GET/POST/PUT/PATCH requests to check whether controller actions work as intended. Normally used for "sad paths" -Model Specs: tests that check that the models work as intended
What are some of the benefits of test-driven development?
Easier to maintain, easier to refactor, high test coverage, less debugging
Where are feature specs located?
/spec/feature
Where are model specs located?
/spec/models/
Where are request specs located?
/spec/requests/
What can we call a test that proves we implemented a high-level feature that the customer/boss/client wants?
Acceptance Test
Why should we use continuous integration?
Because if all the tests passes after the changes have been integrated, we can feel confident that the codebase is high-quality and that we have not introduced any regressions
Why are integration tests generally slower than unit tests?
Because integration tests run in a browser
What is the tool that lets you simulate a browser in tests?
CAPYBARA
What are some of the benefits of automated testing?
Catch bugs sooner, preventing them from being deployed, saves time and money, reduces the manpower to test an entire system
What are the three steps to TDD and what do you do at each step?
Coding, testing (writing unit tests), and designing (refactoring)
What is the tool that lets you write user stories as tests in plain English?
Cucumber
What is Cucumber and which type of testing does it help with?
Cucumber is a tool that helps us write and run feature specs in Rails applications
What are some of the things that code reviewers should look for?
Design, functionality, complexity, consistency and tests
Code Review
Discussion + Code
How does effective branching, automated testing, continuous integrations, pull requests, and code review all help contribute towards preserving a master that is always working and ready to deploy? How does it relate towards the spirit of agile?
Everything will make sure that your software is high-quality. Branching will make sure that there are no problems to be resolved in the master branch, automated testing will save time and give you confidence to change code, CI will ensure that there are no regressions, pull requests help as code review to provide feedback on the features added. This workflow can be related to agile since it values individuals and interactions, working software, customer collaboration, and responding to change.
What is FactoryBot used for?
FactoryBot is a helper for writing factories for Ruby tests, it creates test fixtures, which can be used as a tool to help with automated testing.
What are some of the benefits of code review?
Gets a set of fresh eyes on the code, makes people want to write better code, helps reduce errors before merging
What is the git command to create a new branch?
Git branch branch_name
What is the git command to create and checkout a branch at the same time?
Git checkout -b branch_name
What is the git command to checkout a branch?
Git checkout branch_name
Where do you go if you are unsure of how an application is supposed to work?
Go to the test suite
Why are QA teams not a replacement for good testing practices?
Humans will never be as efficient or scalable as automated tests at catching regressions, it is an expensive mistake. QA teams should be hired in addition to a good testing suite
What are integration tests?
Integration tests are in charge of testing the whole system as a whole, usually by simulating a user trying to accomplish a task in the software
How does good testing practices enable confidence?
It allows you to make large, sweeping changes to your codebase without fearing that you will break something. It gives you confidence to deploy code at 5pm on Friday, and allows you to move faster
Why is it important to not work in master?
Its best to work on branches to facilitate on working on sections and not interfere with code on the main branch
What is one of the biggest obstacles that developers have that stops them from practicing TDD?
Legacy Code creates issues
What is the type of testing used to check that models work as intended?
Model tests
If your code is "red", meaning some of the tests failed in continuous integrations, should you merge it?
No, it should not be merged if tests fail
When should you use inside-out development?
Project is relatively small, you need to refactor from the ground up, and you already know your domain logic and model
What is the tool that allows us to expect certain things and causes a test to fail if the expectation is not met? (This tool is used in all types of Rails testing)
RSPEC
What is it called when new code breaks old code?
Regression
What is the type of testing used to issue direct HTTP calls to the application to check whether our HTTP requests work as intended?
Request Specs
When working on an application, why is it important to consider the sad paths and not just the happy paths?
Sad paths help you figure out what should not happen in a scenario, and these help with preparing to handle errors
How does a test suite serve as living documentation?
Since every test covers a small piece of functionality in your app, it is good for living documentation. Tests must be up to date as opposed to comments
When you open a Pull Request, what do you expect someone on your team to do?
Someone will review the code before merging the changes into the project
What is a test suite?
The collection of tests that ensure that your program works. If you add a feature you cannot say it's "complete" if you have not run your test suite to catch regressions
What is continuous deployment?
The workflow where we push changes to github
What are unit tests?
Unit tests check that individual components in isolation behave correctly, independent of the rest of the system
When should you use outside-in development?
When you are required to implement a new functionality at a different layer, covers use case level functionality or is intended for acceptance tests
When should you not use TDD?
When you have an existing codebase that doesn't have unit tests at all, or when you don't have the time, as TDD is very time consuming
How does continuous integration help maintain a stable master branch?
Whenever someone checks in new code to version control, continuous integration temporarily integrates those changes into the code base and ensures that the test-suite still passes
How do we amplify that confidence and achieve bigger wins in time savings and code?
With TDD, it makes refactoring easier, and with an entire test suite, you can easily improve the code without fear of breaking your application
What is the best way to achieve confidence in a growing code-base?
With TDD, it makes the code base easier to maintain, and there is always high test coverage, which leads to confidence in your code
Are Cucumber tests integration tests?
Yes
Can Cucumber tests be considered acceptance tests?
Yes
Can you have many different branches at the same time?
Yes, they can each be independent from the master branch, then pushed in at different times