The AWS Cloud Development Kit (CDK) allows us to define our cloud infrastructure using code. Instead of clicking through the web UI, or AWS console as it is called, we use code. Code that can be checked into version control for collaboration, annotated with documentation and certainly for testing.
The following post focusses on the testing aspect.
If we choose TypeScript we can initialise a CDK project with the following command after having installed aws-cdk
.
cdk init app --language typescript
The project ends up with a generated empty stack. As the comment states we have not defined anything yet.
…
Unit tests help us to make sure our app works as intended without having to start the app and navigate manually through it after every change. In comparison with UI tests, they test single views in isolation instead of a full user flow. They are a lot faster and more focused.
To start off easy we use ContentView
. It’s initially generated when creating a new project and draws the string “Hello, world!”
in the center of the screen. It’s SwiftUI code.
How would we test whether it draws the string “Hello, world!”
? …
The state of an immutable object cannot be modified after its creation. If the object can be modified after its creation we call it a mutation of the object. In short the object is mutable.
Let’s use an example in Java.
We have list of allowedUsers
, a method to getAllowedUsers
and a method to check whether a username
canUserAccessResource
. We can think of it as a way to do some simple access control such as canUserAccessResource("Mallory")
, which would, and should, return false
. Mallory is not in the list of allowedUsers
.
UI testing in iOS is often criticized for being too slow or hard to maintain. At Porsche Digital, we found a way to avoid the pitfalls and make UI testing more smooth. Here’s how — explained by Axel Hodler who is part of the Software Engineering Chapter at Porsche Digital and has a strong focus on thorough test automation, test-driven development, and keeping things simple.
In comparison with unit tests, the field of UI testing often gets a bad reputation. Depending on the test suite UI tests might be slow, brittle and hard to maintain. Sadly, these drawbacks often turn…
Describing the practice in simple terms
Say we provide a service. Getting a user by its id would return the following infos
curl https://someserver.com/api/users/1{
"id": 1,
"name": "Jane Doe",
"age": 23,
"address": "Somestreet 123 in City"
"premium": true
}
The id, the name, the age, the address and a field whether the user is a premium user. In reality the service might provide a lot more fields.
The consumer of the service could be an app on iOS or Android. A web app. Or any other backend service.
The provider provides, controls and owns the service. A consumer of…
AWS Fargate removes the need to provision and manage services.
When sending mails with Amazon SES the mail will have a sent date. Example: A german user triggers something at 3 PM Berlin time. That in turn sends a mail. Could be a password reset.
Without changes in the timezone the mail will have a sent time before 3 PM when viewed by the german. For example 1 PM during daylight savings time. Unnecessary confusion for the user.
Why? Because the host is using UTC. Fine in general. …
We can use UserDefaults
to store any basic data types. Bool
, Int
, String
and more. The data is loaded when the app starts and removed when the application is deleted from the device.
One example where UserDefaults
comes in handy is to mark wether the user has seen the tutorial. It allows us to not show it to the user again on any subsequent app start.
We store the value if the user has seenTutorial
in a Bool
.
UserDefaults.standard.set(true, forKey: "seenTutorial")
We want to write the following UI tests
…
In the book Programming Bitcoin by Jimmy Song at the end of Chapter 6 we are presented with the following Bitcoin script as part of an exercise.
What is the following supposed to do?
OP_2DUP, OP_EQUAL, OP_NOT, OP_VERIFY, OP_SHA1, OP_SWAP, OP_SHA1, OP_EQUAL
Let’s take a step back. What are we looking at?
It’s a bunch of operation codes. Opcodes. They specify the operation to be performed. They are what makes up Bitcoins Smart Contract Programming language.
Wait. Smart Contracts in Bitcoin? Isn’t that what Ethereum was created for?
In a sense yes. In Ethereum we could be more expressive. For…
By using a password manager the handling of sign up and log in is easy. Although not all the time. Some sites restrict the length or do not allow some characters. In addition the autofill does not always work, which requires us to copy and paste passwords around.
Not everyone uses password managers. As a result the same password is used for multiple sites. Or written down on paper or as a digital note.
Medium supports the login with just an email address. No password. The troubleshooting, at the time of this writing, mentions they do not support passwords.
Setting…
Being around for a while each of us might have seen the following code
if [ -z $1 ]; then
echo "please provide the input parameter foobar"
exit 1
fi# do some work
In the wild it can be found at the beginning of some shell scripts. It is a guard clause.
Our script requires an input and fails if the length of the input is zero. If the length is zero it’s not present. Thus the -z
.
Without the input it would make no sense to continue with the execution of thhe script. As a result we exit…
Building things. Usually by writing code. www.hodler.co. Software Engineering @porschedigital