Lesson 16 - Testing Basics
LEARN
Week 6
- Lesson 15 - Forms Input
- Lesson 16 - Testing
- Lesson 17 - Test Driven Development
CRUD Design Pattern
- CREATE - make a new record
- READ - get one or more records
- UPDATE - modify an existing record
- DELETE - remove a record
Data Views Design Pattern
- CreateView
- ListView
- DetailView
- UpdateView
- DeleteView
Types of Testing
- Manual testing
- Django tests for CRUD
Setup for Workflow
- Create a To Do List
- Test
- Fix
- Features
- Improve
Development Loop
- Select one feature
- Setup automatic test
- Write code to fix test
- Pass test
- Commit changes
BUILD
Running Django from Visual Studio
- Virtual Environment
- launch.json
- runserver
- test
Manual Testing
- Home
- List
- Detail
- Edit
- Add
- Delete
Django TestCase to test database
- Fresh database for testing
- assert
- create test objects (new Superhero)
- setup, teardown
CRUD Test
- List
- Detail
- Edit
- Add
- Delete
Add
Book.objects.create(title='Tale of 2 Cities', author='Charles Dickens')
Book.objects.create(title='Iliad', author='Homer')
List
Book.objects.all()
Detail
b = Book.objects.get(pk=1)
b.title
b.author
Edit
b = Book.objects.get(pk=1)
b.author = 'Chuck Dickens'
b.save()