- Unit testing involves testing individual units or components of a program, such as classes or methods.
- The unittest module provides a framework for writing and running tests in Python. It includes a TestCase class that allows setting up tests and making assertions.
- Writing unit tests involves creating subclasses of TestCase and writing individual test methods that make assertions about the expected output of the code being tested. The setUp method can initialize common values used across tests.
This lecture/presentation cover topic such as C# Introduction, History, The C# Programming Language, The Microsoft .NET Framework, Why C#?, Types of Application, and SharpDevelop 5.1.x
Clean Architecture helps you build applications that are Independent of Frameworks, UI, Database or any external agency. This talk will be an introduction to Clean Architecture principles and system design in Python. We will choose a sample application and walk through a simple use case of creating clean code.
What you will gain from this talk:
* Grow your application with confidence
* Build applications to be independent of infrastructure like Web Frameworks, Database etc.
* Avoid mixing of business logic across different layers of your application
* Test close to 100% of your core business logic
* Keep your tests fast and independent of infrastructure (DB, Web Layer etc.)
This lecture/presentation cover topic such as C# Introduction, History, The C# Programming Language, The Microsoft .NET Framework, Why C#?, Types of Application, and SharpDevelop 5.1.x
Clean Architecture helps you build applications that are Independent of Frameworks, UI, Database or any external agency. This talk will be an introduction to Clean Architecture principles and system design in Python. We will choose a sample application and walk through a simple use case of creating clean code.
What you will gain from this talk:
* Grow your application with confidence
* Build applications to be independent of infrastructure like Web Frameworks, Database etc.
* Avoid mixing of business logic across different layers of your application
* Test close to 100% of your core business logic
* Keep your tests fast and independent of infrastructure (DB, Web Layer etc.)
Object oriented programming with pythonArslan Arshad
A short intro to how Object Oriented Paradigm work in Python Programming language. This presentation created for beginner like bachelor student of Computer Science.
explanation on C# value data types and reference data types. It also explains how they are stored in the heap or stack memory.
Feel free to drop your questions and comments below.
The Liskov Substitution Principle (LSP, lsp) is a concept in Object Oriented Programming that states: Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYAMaulik Borsaniya
Classes and Object-oriented Programming:
Classes: Creating a Class, The Self Variable, Constructor, Types of Variables, Namespaces, Types of Methods (Instance Methods, Class Methods, Static Methods), Passing Members of One Class to Another Class, Inner Classes
Inheritance and Polymorphism: Constructors in Inheritance, Overriding Super Class Constructors and Methods, The super() Method, Types of Inheritance, Single Inheritance, Multiple Inheritance, Method Resolution Order (MRO), Polymorphism, Duck Typing Philosophy of Python, Operator Overloading, Method Overloading, Method Overriding
Abstract Classes and Interfaces: Abstract Method and Abstract Class, Interfaces in Python, Abstract Classes vs. Interfaces,
JUnit: A unit testing framework that is extensively used to test the code written in Java.
Unit testing is a type of software testing.
Software testing: The process of examining whether the software and its components meet the specified requirements
Other types of software testing are as shown.
Our trainer’s having vast experience in real time environment. If anyone has a dream for their career in software programming, then go for java because it is a popular route to establish and fulfill your dreams.
We offer the best quality and affordable training, so you get trained from where you are, from our experienced instructors, remotely using Webex / Gotomeeting.
Object oriented programming with pythonArslan Arshad
A short intro to how Object Oriented Paradigm work in Python Programming language. This presentation created for beginner like bachelor student of Computer Science.
explanation on C# value data types and reference data types. It also explains how they are stored in the heap or stack memory.
Feel free to drop your questions and comments below.
The Liskov Substitution Principle (LSP, lsp) is a concept in Object Oriented Programming that states: Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYAMaulik Borsaniya
Classes and Object-oriented Programming:
Classes: Creating a Class, The Self Variable, Constructor, Types of Variables, Namespaces, Types of Methods (Instance Methods, Class Methods, Static Methods), Passing Members of One Class to Another Class, Inner Classes
Inheritance and Polymorphism: Constructors in Inheritance, Overriding Super Class Constructors and Methods, The super() Method, Types of Inheritance, Single Inheritance, Multiple Inheritance, Method Resolution Order (MRO), Polymorphism, Duck Typing Philosophy of Python, Operator Overloading, Method Overloading, Method Overriding
Abstract Classes and Interfaces: Abstract Method and Abstract Class, Interfaces in Python, Abstract Classes vs. Interfaces,
JUnit: A unit testing framework that is extensively used to test the code written in Java.
Unit testing is a type of software testing.
Software testing: The process of examining whether the software and its components meet the specified requirements
Other types of software testing are as shown.
Our trainer’s having vast experience in real time environment. If anyone has a dream for their career in software programming, then go for java because it is a popular route to establish and fulfill your dreams.
We offer the best quality and affordable training, so you get trained from where you are, from our experienced instructors, remotely using Webex / Gotomeeting.
The presentation explains the PHP unit testing framework and provides a basic training on Testing with PHPunit. It Covers fundamental of unit testing, unit testing benefits and best practices. Starting ground up from PHP unit fundamentals, features of unit testing tries to explore advanced topics like Data providers, Fuxtures, Test doubles and more...
Dreamforce Campfire - Apex Testing Tips and TricksDaniel Ballinger
Useful apex development tools
Unconference description:
"We will cover several useful tools and techniques for working with Apex test cases. This will include running single Apex test methods in isolation and alternative views of test runs."
Evaluating Teaching: SECTIONS.
Check out:
Bates, A. W., & Poole, G. (2003). Effective Teaching with Technology in Higher Education: Foundations for Success. Jossey-Bass, An Imprint of Wiley. 10475 Crosspoint Blvd, Indianapolis, IN 46256.
Evaluating Teaching: Anstey and Watson Rubric
Check out:
Lauren M. Anstey & Gavan P.L. Watson. (2018), Rubric for eLearning Tool Evaluation. Centre for Teaching and Learning, Western University,
http://creativecommons.org/licenses/by-n c-sa/4.0/
Designing Teaching: ASSURE
Check out:
Heinich, R., Molenda, M., & Russell, J. D., (1993). Instructional Media and The New
Technologies of Instruction. New York: Macmillan
Designing Teaching: Laurilliard's Learning TypesDamian T. Gordon
Designing Teaching: Laurilliard's Learning Types
Check out:
Laurillard, D., 2013. Teaching as a design science: Building pedagogical patterns for learning and technology. Routledge.
Designing Teaching: Elaboration Theory
Check out:
Reigeluth, C. & Stein, F. (1983). The elaboration theory of instruction. In C. Reigeluth (ed.), Instructional Design Theories and Models. Hillsdale, NJ: Erlbaum Associates.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
2. Object Oriented Testing
• Unit Testing is concerned with testing small chunks of a
program, for example, testing a single class or a single method.
• Python has a library for unit testing called unittest. It
provides several tools for creating and running unit tests.
3. Object Oriented Testing
• One of the most important classes in unittest is called
TestCase which provides a set of methods to compare
values, set up tests and clean up after tests are finished.
• To write unit tests, we create a subclass of TestCase and
write individual methods to do the actual testing. Typically we
start all of these methods with the name test.
5. Object Oriented Testing
• Let’s look at a simple example:
import unittest
class CheckNumbers(unittest.TestCase):
def test_int_float(self):
self.assertEqual(1, 1.0)
# END test_int_float
# END CheckNumbers
if __name__ == "__main__":
unittest.main()
# ENDIF
6. Object Oriented Testing
• Let’s look at a simple example:
import unittest
class CheckNumbers(unittest.TestCase):
def test_int_float(self):
self.assertEqual(1, 1.0)
# END test_int_float
# END CheckNumbers
if __name__ == "__main__":
unittest.main()
# ENDIF
Create a subclass of
the TestCase class
7. Object Oriented Testing
• Let’s look at a simple example:
import unittest
class CheckNumbers(unittest.TestCase):
def test_int_float(self):
self.assertEqual(1, 1.0)
# END test_int_float
# END CheckNumbers
if __name__ == "__main__":
unittest.main()
# ENDIF
Create a subclass of
the TestCase class
This test checks if the
integer and real
value 1 are equal.
8. Object Oriented Testing
• Let’s look at a simple example:
import unittest
class CheckNumbers(unittest.TestCase):
def test_int_float(self):
self.assertEqual(1, 1.0)
# END test_int_float
# END CheckNumbers
if __name__ == "__main__":
unittest.main()
# ENDIF
Make sure this is
being run as a script
Create a subclass of
the TestCase class
This test checks if the
integer and real
value 1 are equal.
10. Object Oriented Testing
• And if we run this, we get:
.
-------------------------------------------------
Ran 1 test in 0.020s
OK
11. Object Oriented Testing
• And if we run this, we get:
.
-------------------------------------------------
Ran 1 test in 0.020s
OK
Dot means the test has passed
13. Object Oriented Testing
• Let’s try another example:
import unittest
class CheckNumbers(unittest.TestCase):
def test_string_float(self):
self.assertEqual(“1”, 1.0)
# END test_string_float
# END CheckNumbers
if __name__ == "__main__":
unittest.main()
# ENDIF
14. Object Oriented Testing
• Let’s try another example:
import unittest
class CheckNumbers(unittest.TestCase):
def test_string_float(self):
self.assertEqual(“1”, 1.0)
# END test_string_float
# END CheckNumbers
if __name__ == "__main__":
unittest.main()
# ENDIF
This test checks if the
string and real value
1 are equal.
16. Object Oriented Testing
• And if we run this, we get:
F
=========================================================
FAIL: test_string_float (__main__.CheckNumbers)
This test checks if the string and real value 1 are equal.
--------------------------------------------------------
Traceback (most recent call last):
File "C:/Users/damian/AppData/Local/Programs/Python/Python35-
32/CheckNumbers-string-float.py", line 9, in test_string_float
self.assertEqual("1", 1.0)
AssertionError: '1' != 1.0
--------------------------------------------------------
Ran 1 test in 0.060s
FAILED (failures=1)
17. Object Oriented Testing
• And if we run this, we get:
F
=========================================================
FAIL: test_string_float (__main__.CheckNumbers)
This test checks if the string and real value 1 are equal.
--------------------------------------------------------
Traceback (most recent call last):
File "C:/Users/damian/AppData/Local/Programs/Python/Python35-
32/CheckNumbers-string-float.py", line 9, in test_string_float
self.assertEqual("1", 1.0)
AssertionError: '1' != 1.0
--------------------------------------------------------
Ran 1 test in 0.060s
FAILED (failures=1)
“F” means the test has failed
21. Object Oriented Testing
• And if we run this, we get:
.F
=================================================================
FAIL: test_string_float (__main__.CheckNumbers)
---------------------------=-------------------------------------
Traceback (most recent call last):
File "C:UsersdamianAppDataLocalProgramsPythonPython35-
32CheckNumbers.py", line 10, in test_string_float
self.assertEqual("1", 1.0)
AssertionError: '1' != 1.0
-----------------------------------------------------------------
Ran 2 tests in 0.010s
FAILED (failures=1)
22. Object Oriented Testing
• And if we run this, we get:
.F
=================================================================
FAIL: test_string_float (__main__.CheckNumbers)
---------------------------=-------------------------------------
Traceback (most recent call last):
File "C:UsersdamianAppDataLocalProgramsPythonPython35-
32CheckNumbers.py", line 10, in test_string_float
self.assertEqual("1", 1.0)
AssertionError: '1' != 1.0
-----------------------------------------------------------------
Ran 2 tests in 0.010s
FAILED (failures=1)
“.F” means the first test passed and the
second test has failed
24. Object Oriented Testing
• A test case typically sets certain variables to known values, runs
one or more methods or processes, and then show that correct
expected results were returned by using TestCase assertion
methods.
• There are a few different assertion methods available to confirm
that specific results have been achieved. We already saw
assertEqual, which will cause a test failure if the two
parameters do not pass an equality check. The inverse,
assertNotEqual, will fail if the two parameters do compare as
equal.
25. Object Oriented Testing
• The assertTrue and assertFalse methods each accept
a single expression, and fail if the expression does not pass an
IF test. These tests are not checking for the Boolean values
True or False, but instead:
– To pass the assertFalse method the test should return False,
None, 0, or an empty list, dictionary, string, set, or tuple.
– To pass the assertFalse method the test should return True,
non-zero numbers, containers with values in.
26. Methods Description
assertEqual
assertNotEqual
Accept two comparable objects and ensure the named equality
holds.
assertTrue
assertFalse
Accept a single expression, and fail if the expression does not
pass an IF test.
assertGreater
assertGreaterEqual
assertLess
assertLessEqual
Accept two comparable objects and ensure the named
inequality holds.
asssertIn
assertNotIn
Ensure an element is (or is not) an element in a container
object.
assertIsNone
assertIsNotNone
Ensure an element is (or is not) the exact value None (but not
another false value).
assertSameElements Ensure two container objects have the same elements, ignoring
the order.
assertSequenceEqualassertDictEqual
assertSetEqual
assertListEqual
assertTupleEqual
Ensure two containers have the same elements in the same
order. If there's a failure, show a code diff comparing the two
lists to see where they differ. The last four methods also test the
type of the list.
assertRaises Ensure that a specific function call raises a specific exception.
27. Object Oriented Testing
• Let’s look at the assertRaises method in a bit more detail.
• This method can be used to ensure a specific function call
raises a specific exception. The test passes if the code inside
the with statement raises the proper exception; otherwise, it
fails.
29. Object Oriented Testing
• Let’s look at an example:
import unittest
def MyAverage(seq):
return sum(seq) / len(seq)
# END average
Continued
30. • Let’s look at an example:
Object Oriented Testing
class TestAverage(unittest.TestCase):
def test_zero(self):
self.assertRaises(ZeroDivisionError, MyAverage, [])
# END test_zero
def test_with_zero(self):
with self.assertRaises(ZeroDivisionError):
MyAverage([])
# END test_with_zero
# END CLASS TestAverage
Continued
Continued
31. • Let’s look at an example:
Object Oriented Testing
class TestAverage(unittest.TestCase):
def test_zero(self):
self.assertRaises(ZeroDivisionError, MyAverage, [])
# END test_zero
def test_with_zero(self):
with self.assertRaises(ZeroDivisionError):
MyAverage([])
# END test_with_zero
# END CLASS TestAverage
Continued
Continued
We can test if a call to
MyAverage gives an error is
a blank list is passed in
32. • Let’s look at an example:
Object Oriented Testing
class TestAverage(unittest.TestCase):
def test_zero(self):
self.assertRaises(ZeroDivisionError, MyAverage, [])
# END test_zero
def test_with_zero(self):
with self.assertRaises(ZeroDivisionError):
MyAverage([])
# END test_with_zero
# END CLASS TestAverage
Continued
Continued
We can test if a call to
MyAverage gives an error is
a blank list is passed in
The same test, but calling the
method directly, which will
return a divide-by-zero error,
so we need to use the with
statement to tidy up.
33. Object Oriented Testing
• Let’s look at an example:
if __name__ == "__main__":
unittest.main()
# ENDIF
Continued
34. Object Oriented Testing
• Now let’s look at a more detailed example.
• Let’s look at a program, and it’s test program:
Stats.py Stats-test.py
class StatsList class TestValidInputs
def mean
def median
def mode
def test_mean
def test_median
def test_mode
35. Object Oriented Testing
• Here’s stats.py:
from collections import defaultdict
class StatsList(list):
def mean(self):
return sum(self) / len(self)
# END mean
Continued
36. • Here’s stats.py:
Object Oriented Testing
Continued
Continued
def median(self):
if len(self) % 2:
return self[int(len(self) / 2)]
else:
idx = int(len(self) / 2)
return (self[idx] + self[idx-1]) / 2
# ENDIF
# END median
37. • Here’s stats.py:
Object Oriented Testing
Continued
def mode(self):
freqs = defaultdict(int)
for item in self:
freqs[item] += 1
mode_freq = max(freqs.values())
modes = []
for item, value in freqs.items():
if value == mode_freq:
modes.append(item)
# ENDIF
# ENDFOR
return modes
# END mode
38. Object Oriented Testing
• We are going to test this program by creating a new file with
our testing code in it.
• So we’ll import unittest, and use the TestCase class
from it, to create a setUp method to do initialization for each
test.
• The setUp method accepts no arguments, and allows us to do
arbitrary setup before each test is run.
39. Object Oriented Testing
• Here’s stats-test.py:
from stats import StatsList
import unittest
class TestValidInputs(unittest.TestCase):
def setUp(self):
self.stats = StatsList([1,2,2,3,3,4])
# END setUp
Continued
40. Object Oriented Testing
• Here’s stats-test.py:
from stats import StatsList
import unittest
class TestValidInputs(unittest.TestCase):
def setUp(self):
self.stats = StatsList([1,2,2,3,3,4])
# END setUp
Continued
Import the program we’ve just
created, and it’s main class.
41. Object Oriented Testing
• Here’s stats-test.py:
from stats import StatsList
import unittest
class TestValidInputs(unittest.TestCase):
def setUp(self):
self.stats = StatsList([1,2,2,3,3,4])
# END setUp
Continued
Import the program we’ve just
created, and it’s main class.
Import unittest.
42. Object Oriented Testing
• Here’s stats-test.py:
from stats import StatsList
import unittest
class TestValidInputs(unittest.TestCase):
def setUp(self):
self.stats = StatsList([1,2,2,3,3,4])
# END setUp
Continued
Import the program we’ve just
created, and it’s main class.
Import unittest.
Create the setup method, to
set up values to be tested.
43. • Here’s stats-test.py:
Object Oriented Testing
Continued
Continued
def test_mean(self):
self.assertEqual(self.stats.mean(), 2.5)
# END test_mean
44. • Here’s stats-test.py:
Object Oriented Testing
Continued
Continued
def test_median(self):
self.assertEqual(self.stats.median(), 2.5)
self.stats.append(4)
self.assertEqual(self.stats.median(), 3)
# END test_median
45. • Here’s stats-test.py:
Object Oriented Testing
Continued
def test_mode(self):
self.assertEqual(self.stats.mode(), [2,3])
self.stats.remove(2)
self.assertEqual(self.stats.mode(), [3])
# END test_mode
47. Object Oriented Testing
• And if we run this, we get:
...
----------------------------------------------------------
Ran 3 tests in 0.050s
OK
48. Object Oriented Testing
• And if we run this, we get:
...
----------------------------------------------------------
Ran 3 tests in 0.050s
OK
“…” means all three tests have passed
49. Object Oriented Testing
• The setUp method is never explicitly called inside any of the
three test_* methods, the test suite does the call.
• Also note that test_median alters the list, by adding a “4”
to it, yet when test_mode is called, the list has returned to
the values specified in setUp. This shows that setUp is called
individually before each test, to ensure the test class starts
with a clean slate. Tests can be executed in any order, and the
results of one test should not depend on any other tests.
50. Object Oriented Testing
• TestCase also offers a no-argument tearDown method, which
can be used for cleaning up after each and every test on the class
has run.
• This is useful, for example, if we are testing code that does file I/O,
our tests may create new files as a side effect of testing; the
tearDown method can remove these files and ensure the system
is in the same state it was before the tests ran.
• Test cases should never have side effects.