Comments (6)
Created a PR for this if I'm correct and someone is interested. This will, of course, require changes to other branches as well, but I stopped short in case those should be approached differently.
from aem-guides-wknd.
I saw that my PR was approved and merged. Apologies for any confusion caused the typo where I mentioned issue 406.
Anyway, please note that documentation will have to be updated as well here. It's unclear if there's anywhere to update that in a repo, so I'm just leaving a note here.
Also, similar changes will need to be made to the branches unit-testing-solution
as well as main
. It's not clear what your branching strategy is, though. If you just merge those down and keep the branches alive or what.
from aem-guides-wknd.
@prestoncrawford i see where youre going w/ this ... but im struggling to see how breaking these checks out into testable functions gets you anything more at the end of the day.
For example:
You ca test the discrete isXEmpty()
methods, but ultimately the thing we care about is testing isEmpty()
, since that's what our HTL uses (Just because the discrete isXEmpty*() functions pass, doesnt mean there isn't a bug in isEmpty()
).
Ultimately we need to check that isEmpty()
returns false when a) name is empty b) occupations is empty c) image is empty, and that's what the test data is setup to test:
- testIsEmpty_WithoutName -> tests having only occupation and image
- testIsEmpty_WithoutOccupations -> tests having only name and image
- testIsEmpty_WithoutImage -> tests having only name and occupations
- testIsEmpty_WithoutImageSrc -> having only a name and occupations (and non-null image object)
You can of course muck w/ any tests input, but at that point you're writing a bad test and should fix the input. Ultimately tests are intended to allow you to change the code being tested (BylineImpl.java) without breaking existing behavior; since we have 100% code coverage as well - we can be confident that all pathing is covered by our tests (and their respective inputs).
Or maybe asked another way ... if we break the checks out into discrete methods isNameEmpty
, isOccupationsEmpty
and isImageEmpty
- how do you propose writing a test for isEmpty()
that looks like:
public boolean isEmpty() {
// If any of the required fields are empty, the component is considered empty
return isNameEmpty() || isOccupationsEmpty() || isImageEmpty();
}
...that isn't susceptible to returning a false positive if you mess with your input data?
from aem-guides-wknd.
@davidjgonzalez - I'm only proposing a fix to make the tutorial more clear. I understand the intent of isEmpty
as it concerns the HTL.
Sorry if I misunderstood the point of the unit tests. It just struck me that if you're working through this tutorial here, tests like testIsEmpty_WithoutOccupations
don't actually work as expected. You can use the test data that leaves out names, but includes occupations and you will get a false positive on the test. I would think this would be confusing to people running through the tutorial. It was to me.
It caused me to recheck my test data, which is how I found this.
I still think there should be a check of isEmpty. Just that the tests for testIsEmpty_WithoutOccupations
, testIsEmpty_WithoutName
, etc. should be meaningful tests.
from aem-guides-wknd.
@prestoncrawford perhaps the various testisEmpty_withoutXXX should include a comments making it clear:
- What each test includes as part of the test criteria/input
- What each test excludes as part of the test criteria (its in the method name, but could call it out more clearly in a comment).
from aem-guides-wknd.
Updated the tutorial with clarifying text
from aem-guides-wknd.
Related Issues (20)
- Unable to see assets on wknd sites pages HOT 7
- Error while creating AEM project using maven archetype 39 HOT 2
- Publish all pages of a project at once HOT 1
- Expose page content in JSON format HOT 1
- Include WCM Core Email Components
- AEM_6.5_Quickstart incompatibility HOT 3
- Getting error while building HOT 2
- Incorrect replication metadata for editable templates
- GraphQlIT tests are too strict
- Something went wrong when trying to create page from wknd project archetype HOT 2
- Enforce service pack installation with package dependencies
- WKND content spread bad practice wrt to /conf/wknd/settings/wcm HOT 1
- Rewrite rule enhencement
- Login (asmith/asmith or other U/P) on Publish Service does not work in AEMCS HOT 1
- Issue when building while following steps in Experience League Tutorial
- one of the plugins/libraries used does not exists
- 4 errors when building from master straight after checkout HOT 1
- Unable to upload WKND Site - v3.2.0 package
- Redundant jcr:read permission for everyone at /conf
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aem-guides-wknd.