compas-dev / compas-dev/compas_fea2

Lots of functions need unitary tests

Open
#29 8 comments 0 reactions 2 assignees Claimed by @franaudo View on GitHub
enhancement
Dominant language
Python
Stars
14
Forks
10
PR merge metrics
No merged PRs in 30d

Description

I think lots of functions are not so obvious to understand and could easily lead to bugs.
Writing unitary test for them within unittest framework would be a great idea for:

- be sure that the code is bulletproof.
- make refactoring and maintenance much easier
- help to understand what the code does.

Example with this:

```
class Steel(SteelBase):

def __init__(self, name, fy, fu, eu, E, v, p):
super(Steel, self).__init__(name, fy, fu, eu, E, v, p)
self.data = self._generate_data()

def _generate_data(self):
data_section = []
line = """*Material, name={}
*Density
{},
*Elastic
{}, {}
*Plastic""".format(self.name, self.p, self.E['E'], self.v['v'])
data_section.append(line)

for i, j in zip(self.compression['f'], self.compression['e']):
line = """{}, {}""".format(abs(i), abs(j))
data_section.append(line)
return '\n'.join(data_section)
```
If you take a month of holiday and I am in charge of the maintenance without knowing Abaqus, your part of the code, a small test case for this function will give me all the cards in my hand for fixing a bug. I will know exactly what is inside each variable and what to expect from the function.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.