package com.example.apptester
import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val runTestButton: Button = findViewById(R.id.runTestButton)
val testResultText: TextView = findViewById(R.id.testResultText)
runTestButton.setOnClickListener {
val testPassed = runSimpleTest()
if (testPassed) {
testResultText.text = "Test Passed"
} else {
testResultText.text = "Test Failed"
}
}
}
private fun runSimpleTest(): Boolean {
// Simulate a test that checks if 2 + 2 equals 4
return (2 + 2 == 4)
}
}This app screen has a button labeled 'Run Test'. When the user taps it, the app runs a simple test function that checks if 2 + 2 equals 4. This simulates a basic reliability check. The result is shown immediately below the button as 'Test Passed' or 'Test Failed'. This example shows how testing can confirm that parts of the app work as expected, which helps ensure the app is reliable and trustworthy.